db2 的 select for update 的lock mode

DB2  for update 没有加排他锁?

select  * from table_name where id='xx' for update  (id是主键,具有主键索引)

经测试:如上语句并没有给行加U(update)锁,而是S(共享)锁

select  * from table_name where id='xx'

select  * from table_name where id='xx' for update

select  * from table_name where id='xx' for update with CS

如上3条语句效果一样,给查询结果加的都是S锁,1个事务查询到结果,另一个事务仍可以对其查询修改

select  * from table_name where id='xx' for update with RR

select  * from table_name where id='xx' for update with RS

如上两条,对查询结果加的是U锁,1个事务查询结果未提交,令一个事务无法对其update操作

参考:http://blog.chinaunix.net/uid-20313874-id-299469.html

猜你喜欢

转载自zhouchaofei2010.iteye.com/blog/2398212