Ver Mensaje Individual
  #4 (permalink)  
Antiguo 23/02/2010, 03:30
jc3000
 
Fecha de Ingreso: junio-2007
Mensajes: 891
Antigüedad: 17 años, 6 meses
Puntos: 43
Respuesta: Bloqueos de bbdd

Yo uso esta query de manera frecuente.

Cuando hay bloqueos me los muestra con el usuario bloqueado / bloqueador, la maquina de los dos, etc etc etc.
Para ciertas tareas es super util.

SELECT /*+ CHOOSE */
BS.USERNAME "BLOCKING_USER",
BS.USERNAME "DB_USER",
BS.OSUSER "BLOCKING_OSUSER",
WS.USERNAME "WAITING_USER",
WS.OSUSER "WAITING_OSUSER",
BS.SID "SID",
WS.SID "WSID",
BS.SQL_ADDRESS "ADDRESS",
BS.SQL_HASH_VALUE "SQL_HASH",
BS.PROGRAM "BLOCKING_APP",
WS.PROGRAM "WAITING_APP",
BS.MACHINE "BLOCKING_MACHINE",
WS.MACHINE "WAITING_MACHINE",
BS.OSUSER "BLOCKING_OS_USER",
WS.OSUSER "WAITING_OS_USER",
BS.SERIAL# "SERIAL",
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) lock_type,
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)) mode_held,
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)) mode_requested,
TO_CHAR(hk.id1) lock_id1,
TO_CHAR(hk.id2) lock_id2
FROM
gv$lock hk, gv$session bs,
gv$lock wk, gv$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