如何解決ORA-00054資源正忙,要求指定NOWAIT

mengbing1990發表於2016-10-18
1.透過上句查詢出已被鎖定的資料庫表及相關的sid、serial#及spid
    select object_name as 物件名稱,s.sid,s.serial#,p.spid as 系統程式號
    from v$locked_object l , dba_objects o , v$session s , v$process p
    where l.object_id=o.object_id and l.session_id=s.sid and s.paddr=p.addr;

2.在資料庫中滅掉相關session
    alter system kill session 'sid,serial#';--sid及serial#為第一步查出來的資料



SQL> select username,sid,serial#,logon_time from v$locked_object,v$session where v$locked_object.session_id=v$session.sid;
USERNAME                              SID    SERIAL# LOGON_TIME
------------------------------ ---------- ---------- -----------
NEWCCS                               1491      11152 2010-7-6 17

      2.根據SID檢視具體的SQL語句
SQL> select sql_text from v$session,v$sqltext_with_newlines where decode(v$session.sql_hash_value,0,prev_hash_value,sql_hash_value)=v$sqltext_with_newlines.hash_value and v$session.sid=&sid order by piece;
      3.如果短時間內此SQL語句無法完成,且急需重建索引,那麼kill此session
SQL> alter system kill session '1491,11152';

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29551564/viewspace-2126658/,如需轉載,請註明出處,否則將追究法律責任。

相關文章