ORA-00054: resource busy and acquire with NOWAIT specified

ORA-00054: resource busy and acquire with NOWAIT specified
如果不使用NOWAIT等项,默认为等待(WAIT)其他事务提交后在返回结果。

WAIT integer,与NOWAIT的功能相似,但可以等待用户指定的秒数。如:"WAIT 3"等待3秒后,其他事务还没有提交将返回如下结果:
ORA-30006: resource busy; acquire with WAIT timeout expired 。

出现这种问题后查V$LOCKED_OBJECT,要么等事务结束后再做,要么杀掉持有锁的会话(如果不是关键会话):

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#为第一步查出来的数据。

用如下的语句也可以:

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';
这些操作也可用TOAD图形化实施完毕!

你可能感兴趣的:(ORA-00054: resource busy and acquire with NOWAIT specified)