Oracler看锁、查SQL,解锁


ora-00054:resource busy and acquire with nowait specified
From:
http://space.itpub.net/12778571/viewspace-561543

当某个数据库用户在数据库中插入、更新、删除一个表的数据,
或者增加一个表的主键时或者表的索引时,
常常会出现ora-00054:resource busy and acquire with nowait specified这样的错误。
主要是因为有事务正在执行(或者事务已经被锁),所有导致执行不成功。


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

select t2.username,t2.sid,t2.serial#, To_char(t2.logon_time,'yyyy-mm-dd hh24:mi:ss')
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;

结果:

USERNAME                              SID    SERIAL# TO_CHAR(T2.LOGON_TI
------------------------------ ---------- ---------- -------------------
SCOTT                                 128      64382 2010-04-07 12:39:41
SCOTT                                 151       5491 2010-05-12 15:57:35
SCOTT                                 151       5491 2010-05-12 15:57:35
SCOTT                                 105      51006 2010-05-12 16:45:16
SCOTT                                 183      38455 2010-05-12 17:30:13

 


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 = 183;

结果:

SQL_TEXT
----------------------------------------------------------------
hash_value
and a.sid = 183

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.

 

 


3、kill该事务

alter system kill session 'SID  ,  SERIAL#'
alter system kill session '183,38455';

 

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

 


你可能感兴趣的:(sql,.net)