首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

数据库 for update of 跟 for update区别

2012-07-05 
数据库 for update of 和 for update区别。对比区别:  select * from TTable1 for update 锁定表的所有行,

数据库 for update of 和 for update区别。
对比区别:

  select * from TTable1 for update 锁定表的所有行,只能读不能写

select * from TTable1 where pkid = 1 for update 只锁定pkid=1的行

select * from Table1 a join Table2 b on a.pkid=b.pkid for update 锁定两个表的所有记录

  select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update 锁定两个表的中满足条件的行



   select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update of a.pkid 只锁定Table1中满足条件的行



for update 是把所有的表都锁定

for update of 根据of 后表的条件锁定相对应的表



如果加了for update后 该语句用来锁定特定的行(如果有where子句,就是满足where条件的那些行)。当这些行被锁定后,其他会话可以选择这些行,但不能更改或删除这些行,直到该语句的事务被commit语句或rollback语句结束为止。

热点排行