事务的隔离级别的演示:避免不可重复读

1.1.1 演示避免不可重复读
l 分别开启两个窗口A,B
l 设置A窗口的隔离级别:repeatable read;
SET SESSION TRANSACTION ISOLATION LEVEL repeatable read;
事务的隔离级别的演示:避免不可重复读
l 在A,B两个窗口中开启事务:
start transaction;
l 在B窗口完成转账
update account set money = money - 1000 where name= '小张';
update account set money = money + 1000 where name= '小凤';
事务的隔离级别的演示:避免不可重复读
未提交事务!!!
l 在A窗口中进行查询
select
from account;
**** 发现没有转账成功:说明避免脏读!!!
l 在B窗口中提交事务
commit;
l 在A窗口中再次查询:
事务的隔离级别的演示:避免不可重复读
发现在一个事务中的多次查询结果是一致!!!(已经避免不可重复读)。

猜你喜欢

转载自blog.51cto.com/13587708/2113405