Tag Archives: locked

How to view all currently locked objects in database

SELECT username  U_NAME, owner OBJ_OWNER,
object_name, object_type, s.osuser,
DECODE(l.block,
0,  ‘Not Blocking’,
1,  ‘Blocking’,
2,  ‘Global’) STATUS,
DECODE(v.locked_mode,
0,  ‘None’,
1,  ‘Null’,
2,  ‘Row-S (SS)’,
3,  ‘Row-X (SX)’,
4,  ‘Share’,
5,  ‘S/Row-X (SSX)’,
6,  ‘Exclusive’, TO_CHAR(lmode)
) MODE_HELD
FROM gv$locked_object v, dba_objects d,
gv$lock l, gv$session s
WHERE v.object_id = d.object_id
AND (v.object_id = l.id1)
AND  v.session_id = s.sid
ORDER BY username, session_id;

How to check the locked objects in the database

SELECT l.inst_id,SUBSTR(L.ORACLE_USERNAME,1,8) ORA_USER, SUBSTR(L.SESSION_ID,1,3) SID,
S.serial#,
SUBSTR(O.OWNER||’.’||O.OBJECT_NAME,1,40) OBJECT, P.SPID OS_PID,
DECODE(L.LOCKED_MODE, 0,’NONE’,1,’NULL’,2,’ROW SHARE’,3,’ROW EXCLUSIVE’,4,’SHARE’,5,’SHARE ROW EXCLUSIVE’,
6,’EXCLUSIVE’,
NULL) LOCK_MODE
FROM sys.GV_$LOCKED_OBJECT L, DBA_OBJECTS O, sys.GV_$SESSION S, sys.GV_$PROCESS P
WHERE L.OBJECT_ID = O.OBJECT_ID
and    l.inst_id = s.inst_id
AND L.SESSION_ID = S.SID
and    s.inst_id = p.inst_id
AND S.PADDR = P.ADDR(+)
order by  l.inst_id ;

select * from sys.GV_$LOCKED_OBJECT;