Oracle 结束死锁
1.查询死锁
SELECT s.username,l.OBJECT_ID,l.SESSION_ID,s.SERIAL#,
l.ORACLE_USERNAME,l.OS_USER_NAME,l.PROCESS
FROM V$LOCKED_OBJECT l,V$SESSION S WHERE l.SESSION_ID=S.SID;
2.解锁死锁
alter system kill session ‘sid,serial#’;
注:sid=l.SESSION_ID serial#=s.SERIAL#
3.批量查询结束死锁
select Distinct 'alter system kill session '||chr(39)||b.sid||','||b.serial#||chr(39)||';'As kill对象sql语句,
b.username,b.logon_time
from v$locked_object a,v$session b
where a.session_id=b.sid
order by b.logon_time;