Oracle Lock Information Queries

chncaesar發表於2013-11-19
--Find out what objects are locked.
select
   c.owner,
   c.object_name,
   c.object_type,
   b.sid,
   b.serial#,
   b.status,
   b.osuser,
   b.machine
from
   v$locked_object a ,
   v$session b,
   dba_objects c
where
   b.sid = a.session_id
and
   a.object_id = c.object_id;

--Find out all blocking locks
select * from v$lock where block > 0;

--Find out blocker and blockee
select
(select username || ' - ' || osuser from v$session where sid=a.sid) blocker,
a.sid || ', ' ||
(select serial# from v$session where sid=a.sid) sid_serial,
' is blocking ',
(select username || ' - ' || osuser from v$session where sid=b.sid) blockee,
b.sid || ', ' ||
(select serial# from v$session where sid=b.sid) sid_serial
from v$lock a, v$lock b
where a.block = 1
and b.request > 0
and a.id1 = b.id1
and a.id2 = b.id2;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/638844/viewspace-776963/,如需轉載,請註明出處,否則將追究法律責任。

相關文章