银行有两个客户
银行总存款 表:T_Money 字段:totalMoney:1000
客户一对应 T1 取走100
declare decimal(12,4) @totalMoney;
select @totalMoney=totalMoney from T_Money
update T_Money set totalMoney= @totalMoney-100
客户一对应 T2 取走50
declare decimal(12,4) @totalMoney;
select @totalMoney=totalMoney from T_Money
update T_Money set totalMoney= @totalMoney-50
假如T1 T2并发了
两个是否的@totalMoney都读了1000
假如T1先更新把totalMoney更新为900了,T2后更新,因为读到的totalMoney为1000所以把totalMoney更新为950了,实际上应该两个事务执行完,正确的totalMoney为850
问:
1、这样的情况乐观的并发能控制到么?
2、事务隔离级别能控制到么?
3、到底是怎么控制的- -。