1)执行下面SQL,先查看哪些表被锁住了:
select b.owner,b.object_name,a.session_id,a.locked_mode
from v$locked_object a,dba_objects b
where b.object_id = a.object_id;
2)查处引起死锁的会话
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid order by b.logon_time;
这里会列出SID
3)查具体表的锁表
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b,dba_objects c
where c.object_id = a.object_id
and a.session_id = b.sid
and c.object_name like '%JJIN_DDFJ%'
order by b.logon_time;
4) 查出SID和SERIAL#:
查V$SESSION视图:
SELECT SID,SERIAL#,PADDR FROM V$SESSION WHERE SID='刚才查到的SID';
这一步将得到PADDR
5)查V$PROCESS视图:
SELECT SPID FROM V$PROCESS WHERE ADDR='刚才查到的PADDR';
这一步得到SPID
6)杀死进程
(1)在数据库中,杀掉ORACLE进程:
ALTER SYSTEM KILL SESSION '查出的SID,查出的SERIAL#';