;
set line 1000
col
SELECT /*+ rule */ s.username,
decode(l.type,'TM','TABLE LOCK',
'TX','ROW LOCK',
NULL) LOCK_LEVEL,
o.owner,o.object_name,o.object_type,
s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser
FROM v$session s,v$lock l,dba_objects o
WHERE l.sid = s.sid
AND l.id1 = o.object_id(+)
AND s.username is NOT Null;
set line 1000
col object_name for a40
select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid and
ao.object_name=upper('test');
SELECT
C.SID
FROM ALL_OBJECTS A, V$LOCKED_OBJECT B, SYS.GV_$SESSION C
WHERE (A.OBJECT_ID = B.OBJECT_ID)
AND (B.PROCESS = C.PROCESS) and a.object_name='&tb'
ORDER BY 1, 2;
set line 1000
select a.inst_id,
c.username,
a.sid,
c.serial#,
c.program,
' is blocking ',
b.inst_id,
d.username,
b.sid,
d.serial#,
d.program
from (select inst_id, sid, id1, id2 from gv$lock where block >0) a,
(select inst_id, sid, id1, id2 from gv$lock where request > 0) b,
(select inst_id,sid, serial#, username,osuser, terminal, program
from gv$session) c,
(select inst_id,sid,
serial#,
username,
program from gv$session) d
where a.id1 = b.id1
and a.id2 = b.id2
评论