Oracle诊断:drop table失败[转]

: From <http://blog.csdn.net/cyxlxp8411/article/details/7775113>

 

今天在drop一张表的时候报ORA-00054错误

 

SQL> drop table t2;

drop table t2

           *

ERROR at line 1:

ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

 

google之后,参考网上的高手,操作如下:

 

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

 

SQL> select t2.username,t2.sid,t2.serial#,t2.logon_time

  2  from v$locked_object t1,v$session t2

  3  where t1.session_id=t2.sid order by t2.logon_time;

 

USERNAME                              SID    SERIAL# LOGON_TIM

------------------------------ ---------- ---------- ---------

CLS                                     1          7 23-JUL-12

CLS                                     1          7 23-JUL-12

 

知道被锁的用户cls,sid1serial#7

 

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

 

SQL> select sql_text from v$session a,v$sqltext_with_newlines b

  2  where DECODE(a.sql_hash_value,0,prev_hash_value,sql_hash_value)=b.hash_value

  3  and a.sid=&sid order by piece;

Enter value for sid: 1

old   3: and a.sid=&sid order by piece

new   3: and a.sid=1 order by piece

 

SQL_TEXT

----------------------------------------------------------------

DELETE FROM PLAN_TABLE WHERE STATEMENT_ID=:1

 

3.kill该事务

 

SQL> alter system kill session '1,7';

 

System altered.

 

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

 

SQL> drop table t2;

 

Table dropped.

原文地址:https://www.cnblogs.com/recognition/p/5388099.html