前言
锁表处理
定时器程序
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-oBtM9e7W-1606715924876)(http://47.107.242.88:4999/server/…/Public/Uploads/2020-09-27/5f6ffa9c8ed49.png)]
查询顺序
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#';