锁定数据行 for update和for update nowait

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了锁定数据行 for update和for update nowait相关的知识,希望对你有一定的参考价值。

锁定数据行

select * from emp t where t.deptno=‘20‘  

for update nowait;

这样就锁定了emp表中deptno = 20的那行数据

注意:通过for update锁定后,这些行不能修改了,但是还可以查询


for update和for update nowait

使用for update锁定行,对这行执行update,delete,select .. for update语句都会阻塞,即等待锁的释放后继续执行

使用for update nowait锁定行,对这行执行update,delete,select .. for udapte语句,会马上返回一个“ORA-00054:resource busy”错误,不用一直等待锁的释放后继续执


以上是关于锁定数据行 for update和for update nowait的主要内容,如果未能解决你的问题,请参考以下文章