oracle 锁表查看与解锁

时间:2022-06-05 08:29:11

查看被锁的表:

select l.session_id,o.owner,o.object_name
from v$locked_object l,dba_objects o
where l.object_id=o.object_id;

查看被锁表的serial:

select t2.username,t2.sid,t2.serial#,t2.logon_time
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;

整合:

select a.SESSION_ID,c.SERIAL#,b.OBJECT_NAME,b.OWNER ,c.LOGON_TIME
from v$locked_object a,dba_objects b,v$session c
where a.OBJECT_ID = b.OBJECT_ID and a.SESSION_ID = c.SID

kill 锁表session:

alter system kill session 'sid,serial#';

kill有风险,kill需谨慎