`
zhouchaofei2010
  • 浏览: 1086013 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

db2 的 select for update 的lock mode

    博客分类:
  • DB2
阅读更多

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

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics