鎖定數據行 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”錯誤,不用一直等待鎖的釋放後繼續執


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章