1. 程式人生 > >鎖定數據行 for update和for update nowait

鎖定數據行 for update和for update nowait

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