数据库 数据隔离等级
最近在复习数据库,关于隔离等级这一块有些疑问,希望大佬解惑
四种隔离等级:read uncommitted, read committed, repeatable read, serialization
其中read committed解决了脏读问题,具体是怎么解决的?
如:数据库处于read committed态
事务A 事务B
select * from t where a=1;
update t set a=2 where a=1;
select * from t where a=1;
commit;
commit;
select * from t where a=1;
事务A进行了三次查询,第一次结果为a=1,第二次结果为a=1(即阻止了脏读),第三次结果为empty set(即出现了不可重复读现象)
最终问题:
1. read committed是怎样阻止脏读的?
2. repeatable read是怎样实现可重复读的?