當某個數據庫用戶在數據庫中插入、更新、刪除一個表的數據,或者增加一個表的主鍵時或者表的索引時, 有時會出現ora-00054:resource busy and acquire with nowait specified這個問題,主要原因是事務正在執行或鎖表,具體解決方案如下:
1.查看鎖:
select t2.username,t2.sid,t2.serial#,t2.logon_time
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;
2.查看造成鎖表的sql語句
select sql_text from v$session a,v$sqltext_with_newlines b
where DECODE(a.sql_hash_value, 0, prev_hash_value, sql_hash_value)=b.hash_value
and a.sid=&sid order by piece;
查看造成死鎖的語句(等同於一二步驟):
select a.username ,a.sid, a.serial#, a.last_call_et "Seconds", b.event, c.sql_text
from v$session a, v$session_wait b, v$sqlarea c
where a.sid = b.sid
and a.sql_hash_value = c.hash_value
and b.wait_class not like 'Idle'
3.kill鎖
alter system kill session '339,13545';