Oracle解锁,解决“ora00054:资源正忙”错误
一.处理步骤:
--1.获取被锁对象的session_id
SELECT session_id FROM v$locked_object;
--2.通过session_id获取v$session的sid和serial#
SELECT sid, serial#, username, osuser FROM v$session where sid = session_id;
--3.终止相关进程。
ALTER SYSTEM KILL SESSION 'sid,serial';
或者通过下面语句直接查出
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;
如果在kill 过程中,提示报错
ora-00031:session marked for kill(标记要终止的会话)
解决方法:查出session的spid
select spid, osuser, s.program
from v$session s, v$process p
where s.paddr = p.addr
and s.sid =197;
1. 在linux上, kill -9 12345
2. 在windows上,C:\Documents and Settings\gg>orakill orcl 12345
二.示例:
SQL> select session_id from v$locked_object;
SESSION_ID
----------
141
SQL> SELECT sid, serial#, username, osuser FROM v$session where sid = 141;
SID SERIAL# USERNAME OSUSER
---------- ---------- ------------------------------ ------------------------------
141 41464 VC VC02\Admin
SQL> ALTER SYSTEM KILL SESSION '141,41464';
System altered
SQL> select session_id from v$locked_object;
SESSION_ID
----------