Oracle 存储包死锁杀进程操作
Oracle 存储包死锁杀进程操作
突然想起来,正好记一份
首先查询锁包的情况
select distinct session_id from dba_ddl_locks where name=upper('XXXX');
假设查询结果为('64','58','2296','1527','2292','788','55','1534','2331','1568')
则找到其中一个,通过session查询 t.sid,t.serial#
select t.sid,t.serial# from v$session t where t.sid = '1568';--64,31799
用t.sid,t.serial# 杀进程
alter system kill session '1568,7699';--t.sid,t.serial#
另一种方法,这个方法可以查到锁住的update进程
先用语句查询一下
select object_name, machine, s.sid, s.serial#
from v$locked_object l, dba_objects o, v$session s
where l.object_id = o.object_id
and l.session_id = s.sid
AND OBJECT_NAME LIKE '%表名/包名等等%'
然后通过 s.sid, s.serial#对锁进行删除
alter system kill session 'SID,serial#';
或者使用下面这个
SELECT 'alter system kill session ' || '''' || lo.SESSION_ID || ',' || vss.SERIAL# || ''' immediate;',
dob.OBJECT_NAME Table_Name,
lo.SESSION_ID,
lo.locked_mode,
vss.SERIAL#,
vss.action Action,
vss.osuser OSUSER,
vss.LOGON_TIME,
vss.process AP_PID,
VPS.SPID DB_PID
from v$locked_object lo, dba_objects dob, v$session vss, V$PROCESS VPS
where lo.OBJECT_ID = dob.OBJECT_ID
and lo.SESSION_ID = vss.SID
AND VSS.paddr = VPS.addr
order by lo.SESSION_ID, lo.LOCKED_MODE, DOB.object_name;
将输出的语句直接执行就可以了
以上
您能读到这儿,我呢是发自真心的感谢您,若要转载,还望请您带上链接