1、找到正在执行的存储过程的 sid ,serial#
select b.sid,b.SERIAL#,a.OBJECT, 'alter system kill session ' || '''' || b.sid || ',' ||b.SERIAL# || ''';' kill_command
from SYS.V_$ACCESS a, SYS.V_$session b
where a.type = 'PROCEDURE'
and (a.OBJECT like upper('%存储过程名%') or
a.OBJECT like lower('%存储过程名%'))
and a.sid = b.sid
and b.status = 'ACTIVE';
2、Kill 正在执行的存储过程
alter system kill session 'sid,SERIAL#';
3、查询正在执行的存储过程另外一种方法
select name from v$db_object_cache where locks > 0 and pins > 0 and type='PROCEDURE';
-
oracle的死锁
查询数据库死锁
select t2.username,t2.sid,t2.serial#,t2.logon_time,t3.sql_text
from v$locked_object t1,v$session t2,v$sqltext t3
where t1.session_id=t2.sid
and t2.sql_address=t3.address
order by t2.logon_time;
4、找到正在执行的包的 sid ,serial#
select b.sid,b.SERIAL#,a.OBJECT, 'alter system kill session ' || '''' || b.sid || ',' ||b.SERIAL# || ''';' kill_command
from SYS.V_$ACCESS a, SYS.V_$session b
where a.type = 'PACKAGE'
and a.sid = b.sid
and b.status = 'ACTIVE';
查询出来的结果就是有死锁的session了,
下面就是杀掉
拿到上面查询出来的SID和SERIAL#,填入到下面的语句中
alter system kill session 'sid,serial#';
一般情况可以解决数据库存在的死锁了
转自:http://blog.csdn.net/rfb0204421/article/details/7587554