参考10g2 db concept ,文件有点大能传么?
感谢公司DBA
1.
transaction1
step1:set transaction isolation level serializable -- trans starts
step4:select * from eis_users_temp where id=803939
=======================
transaction2
step2:
update eis_users_temp set first_name = 'bo' where id=803939
step3:commit
执行顺序:step1;step2,step3;step4
step4 不能看到修改后的结果!!That is serializable
换成:set transaction isolation level read committed; 可以看到结果(这个也是oracle默认的隔离设置)
set transaction read only; -- 不能做任何DML,DDL操作,只能select!,它是serializable的子集,所以也看不到修改
把update换成
Insert into eis_users_temp (select * from eis_users_temp where id=803939);
delete from eis_users_temp where id=803939
也是同样的结果
2.
transaction1
step1:set transaction isolation level serializable -- trans starts
step4:
update eis_users_temp set first_name = 'bo1'
where id=803939
=======================
transaction2
step2:
update eis_users_temp set first_name = 'bo2' where id=803939
step3:commit
执行顺序:step1;step2,step3;step4
执行结果:更新为bo2, transaction1企图修改同一条数据 803939 报错
修改另外一条数据801660,没有问题!!
update eis_users_temp set first_name = 'bo1'
where id=801660
commit 变成rollback,也没有问题
如果换成:set transaction isolation level read committed; 都不会有错
================================================
serializable & read committed都是row level locking
read only is Table Locks ?
read committed的情况下
T1
update eis_users_temp set first_name = 'bo1'
where id=803939
T2
update eis_users_temp set first_name = 'bo2'
where id=803939
T1->T2 .都能够执行,但是T1 不COMMIT,T2会阻塞。显然的
oracle在行级别只有X独占锁
但是要注意的是加在行级别,如果修改不同的数据是没有问题的
=====================================
Trans1:
select * from eis_users where id <> 803939 for update
Trans2:
select * from eis_users where id=803939 for update
这两个是不会冲突的 ,select * for update 是行级锁