--Locks (holding):
select /*+ ORDERED */ ctime,type,
decode(block,
0, 'Not Blocking',
1, 'Blocking',
2, 'Global',
to_char(block)) blocking,
decode(lmode,
0, '0 None',
1, '1 Null',
2, '2 Row-S (SS)',
3, '3 Row-X (SX)',
4, '4 Share',
5, '5 S/Row-X (SSX)',
6, '6 Exclusive',
to_char(lmode)) held,
decode(request,
0, '0 None',
1, '1 Null',
2, '2 Row-S (SS)',
3, '3 Row-X (SX)',
4, '4 Share',
5, '5 S/Row-X (SSX)',
6, '6 Exclusive',
to_char(request)) requested,
o.owner as owner_or_type, o.object_Name as NAME
from v$lock l, sys.all_objects o
where type = 'TM'
and l.sid = :sid
and o.object_id = l.id1
union all
select /*+ ORDERED */ ctime,type,
decode(block,
0, 'Not Blocking',
1, 'Blocking',
2, 'Global',
to_char(block)) blocking,
decode(lmode,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, '4 WAIT for ITL free',
5, 'S/Row-X (SSX)',
6, '6 ITL entry',
to_char(lmode)) held,
decode(request,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
to_char(request)) requested,
'ROLLBACK' as owner_or_type, r.name as NAME
from v$lock l, v$rollname r
where type = 'TX'
and l.sid = :sid
and r.usn = trunc(l.ID1/65536)
union all
select /*+ ORDERED */ ctime,type,
decode(block,
0, 'Not Blocking',
1, 'Blocking',
2, 'Global',
to_char(block)) blocking,
decode(lmode,
0, '0 None',
1, '1 Null',
2, '2 Row-S (SS)',
3, '3 Row-X (SX)',
4, '4 Share',
5, '5 S/Row-X (SSX)',
6, '6 Exclusive',
to_char(lmode)) held,
decode(request,
0, '0 None',
1, '1 Null',
2, '2 Row-S (SS)',
3, '3 Row-X (SX)',
4, '4 Share',
5, '5 S/Row-X (SSX)',
6, '6 Exclusive',
to_char(request)) requested,
'LOCK NAME' as owner_or_type, nvl(al.name, l.id1) as NAME
from v$lock l, sys.dbms_lock_allocated al
where type = 'UL'
and l.sid = :sid
and al.lockid (+) = l.id1