Возвращает строки, когда блокировки присутствуют:
SELECT
' Blocking_user : ' || bs.username || chr(13)||chr(10)||
' DB_user : ' || bs.username || chr(13)||chr(10)||
' Waiting_user : ' || ws.username || chr(13)||chr(10)||
' Blocking_SID : ' || bs.SID || chr(13)||chr(10)||
' Blocking_Serial# : ' || bs.serial# || chr(13)||chr(10)||
' Waiting_SID : ' || ws.SID || chr(13)||chr(10)||
' Blocking_App : ' || bs.program || chr(13)||chr(10)||
' Waiting_App : ' || ws.program || chr(13)||chr(10)||
' Blocking_machine : ' || bs.machine || chr(13)||chr(10)||
' Waiting_machine : ' || ws.machine || chr(13)||chr(10)||
' Blocking_OS_user : ' || bs.osuser || chr(13)||chr(10)||
' Waiting_OS_user : ' || ws.osuser || chr(13)||chr(10)||
' lock_type : ' ||
DECODE (
wk.TYPE,
'MR', 'Media Recovery',
'RT', 'Redo Thread',
'UN', 'USER Name',
'TX', 'Transaction',
'TM', 'DML',
'UL', 'PL/SQL USER LOCK',
'DX', 'Distributed Xaction',
'CF', 'Control FILE',
'IS', 'Instance State',
'FS', 'FILE SET',
'IR', 'Instance Recovery',
'ST', 'Disk SPACE Transaction',
'TS', 'Temp Segment',
'IV', 'Library Cache Invalidation',
'LS', 'LOG START OR Switch',
'RW', 'ROW Wait',
'SQ', 'Sequence Number',
'TE', 'Extend TABLE',
'TT', 'Temp TABLE',
wk.TYPE) || chr(13)||chr(10)||
' Mode_held : ' ||
DECODE (
hk.lmode,
0, 'None',
1, 'NULL',
2, 'ROW-S (SS)',
3, 'ROW-X (SX)',
4, 'SHARE',
5, 'S/ROW-X (SSX)',
6, 'EXCLUSIVE',
TO_CHAR (hk.lmode)) ||chr(13)||chr(10)||
' Mode_req : ' ||
DECODE (
wk.request,
0, 'None',
1, 'NULL',
2, 'ROW-S (SS)',
3, 'ROW-X (SX)',
4, 'SHARE',
5, 'S/ROW-X (SSX)',
6, 'EXCLUSIVE',
TO_CHAR (wk.request)) ||chr(13)||chr(10)||
' Id1 : ' || TO_CHAR (hk.id1) || chr(13)||chr(10)||
' Id2 : ' || TO_CHAR (hk.id2)
FROM
v$lock hk,
v$session bs,
v$lock wk,
v$session ws
WHERE hk.BLOCK = 1
AND hk.lmode != 0
AND hk.lmode != 1
AND wk.request != 0
AND wk.TYPE(+) = hk.TYPE
AND wk.id1(+) = hk.id1
AND wk.id2(+) = hk.id2
AND hk.SID = bs.SID(+)
AND wk.SID = ws.SID(+)
ORDER BY 1;