ORA-00054:resource busy and acquire with nowait specified解决方法

时间:2021-08-23 21:02:20

1、用dba权限的用户查看数据库都有哪些锁

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;

如:testuser 339 13545 2009-3-5 17:40:05
        知道被锁的用户testuser,sid为339,serial#为13545

2、根据sid查看具体的sql语句,如果sql不重要,可以kill

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;

查出来的sql,如: BEGIN :ID := SYS.DBMS_TRANSACTION.LOCAL_TRANSACTION_ID; END;

3、kill该事务
       ALTER SYSTEM KILL SESSION '339,13545';

4、这样就可以执行其他的事务sql语句了

如给表加一列:    
       ALTER TABLE TEST ADD ORG_NAME VARCHAR2(50)