oracle-for update 与 for update of
2013-10-28 17:10
260 查看
1 select * from TTable1 for update 锁定表的所有行,只能读不能写
2 select * from TTable1 where pkid = 1 for update 只锁定pkid=1的行
3 select * from Table1 a join Table2 b on a.pkid=b.pkid for update 锁定两个表的所有记录
4 select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update 锁定两个表的中满足条件的行
5. 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 后表的条件锁定相对应的表
select * from emp where empno = 7369 for update; 会对表中员工编号为7369的记录进行上锁。其他用户无法对该记录进行操作,只能查询。select * from emp where empno = 7369 for update of sal; 这条语句是不是意味着只对表中的7369 这一行的sal字段的数据进行了上锁,其他数据则可以被其他用户做更新操作呢。学员测试结果为二条语句的效果是一样的。
在对多个表进行锁定时for update of才会起作用,用户1进行如下操作(of 后面可以使table1中任意字段):
select * from table1 a, table2 b where a.filed1 = b.filed1
for update of a.filed1 ;
用户2进行如下操作时可以对table2进行锁定,因为用户1只对table1进行了锁定:
select * from table2 b
for update
2 select * from TTable1 where pkid = 1 for update 只锁定pkid=1的行
3 select * from Table1 a join Table2 b on a.pkid=b.pkid for update 锁定两个表的所有记录
4 select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update 锁定两个表的中满足条件的行
5. 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 后表的条件锁定相对应的表
select * from emp where empno = 7369 for update; 会对表中员工编号为7369的记录进行上锁。其他用户无法对该记录进行操作,只能查询。select * from emp where empno = 7369 for update of sal; 这条语句是不是意味着只对表中的7369 这一行的sal字段的数据进行了上锁,其他数据则可以被其他用户做更新操作呢。学员测试结果为二条语句的效果是一样的。
在对多个表进行锁定时for update of才会起作用,用户1进行如下操作(of 后面可以使table1中任意字段):
select * from table1 a, table2 b where a.filed1 = b.filed1
for update of a.filed1 ;
用户2进行如下操作时可以对table2进行锁定,因为用户1只对table1进行了锁定:
select * from table2 b
for update
相关文章推荐
- 数据库 oracle for update of 和 for update区别【经典】
- oracle 中 for update与for update of的区别
- ORACLE FOR UPDATE与FOR UPDATE OF区别
- oracle 中 for update与for update of的区别
- oracle-for update 与 for update of
- Oracle for update/for update of/update的用法和区别
- oracle for update 和 for update of的区别
- oracle for update of和for update区别
- oracle PL/SQL-FOR UPDATE 与 FOR UPDATE OF的区别
- Oracle select for update & for update of
- 数据库 oracle for update of 和 for update区别【经典】
- (转) 数据库 oracle for update of 和 for update区别【经典】
- 数据库 oracle for update of 和 for update区别
- 数据库 oracle for update of 和 for update区别
- [转]oracle for update和for update nowait的区别
- Oracle编辑数据时提示:这些查询结果不可更新,请使用ROWI或者SELECT……FOR UPDATE获得可更新结果
- PL/SQL-FOR UPDATE 与 FOR UPDATE OF的区别
- 用锁实现SQLSERVER中并发控制--实现Oracle中select .... for update功能
- oracle for update和for update nowait的区别 - 转
- IBM Software Requirements and PTFs for AIX 5.3 support of Oracle Database 10g Release 2 (10.2.0.1 or higher)