oracle查锁表
查锁表:
SELECT l.inst_id ,s.MACHINE, client_info, s.sid, s.serial# ,object_name, os_user_name,oracle_username ,
locked_mode, s.program,prev_exec_start,logon_time, wmsys.wm_concat(c.sql_text) sql
FROM gv$locked_object l, dba_objects o, gv$session s , gv$open_cursor c
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
and l.inst_id=c.inst_id
and s.sid=c.sid
and l.inst_id=s.inst_id
group by l.inst_id ,s.MACHINE, client_info, s.sid, s.serial# ,object_name, os_user_name,oracle_username ,
locked_mode, s.program,prev_exec_start,logon_time;
select a.SID,b.sid,a.block,a.TYPE,b.request,
(select username||':'||sid||','||serial# from gv$session where sid=a.sid and inst_id=a.inst_id) ||
' 阻塞了 ' ||
(select username ||':'||sid||','||serial# from gv$session where sid=b.sid and inst_id=b.inst_id)
,(select 'alter system kill session '''||sid||','||serial#||''' immediate;'from gv$session where sid=a.sid and inst_id=a.inst_id)
from gv$lock a, gv$lock b
where a.block>0
and b.request > 0
and a.id1 = b.id1
and a.id2 = b.id2
and a.sid<>b.sid ;