Donnerstag, 22. September 2016

Get information on locks

select C.OWNER
     , C.OBJECT_NAME
     , C.OBJECT_TYPE
     , B.SID
     , B.SERIAL#
     , B.STATUS
     , B.OSUSER
     , B.MACHINE
     , case A.LOCKED_MODE
          when 1 then 'No Lock'
          when 2 then 'Row Share'
          when 3 then 'Row Exclusive'
          when 4 then 'Shared Table'
          when 5 then 'Shared Row Exclusive'
          when 6 then 'Exclusive'
       end
          as LOCKED_MODE
     , case L.type
          when 'BL' then 'Buffer Cache Management (PCM lock)'
          when 'CF' then 'Controlfile Transaction'
          when 'CI' then 'Cross Instance Call'
          when 'CU' then 'Bind Enqueue'
          when 'DF' then 'Data File'
          when 'DL' then 'Direct Loader'
          when 'DM' then 'Database Mount'
          when 'DR' then 'Distributed Recovery'
          when 'DX' then 'Distributed Transaction'
          when 'FS' then 'File Set'
          when 'IN' then 'Instance Number'
          when 'IR' then 'Instance Recovery'
          when 'IS' then 'Instance State'
          when 'IV' then 'Library Cache Invalidation'
          when 'JQ' then 'Job Queue'
          when 'KK' then 'Redo Log Kick'
          when 'LA' then 'Library Cache Lock'
          when 'LB' then 'Library Cache Lock'
          when 'LC' then 'Library Cache Lock'
          when 'LD' then 'Library Cache Lock'
          when 'LE' then 'Library Cache Lock'
          when 'LF' then 'Library Cache Lock'
          when 'LG' then 'Library Cache Lock'
          when 'LH' then 'Library Cache Lock'
          when 'LI' then 'Library Cache Lock'
          when 'LJ' then 'Library Cache Lock'
          when 'LK' then 'Library Cache Lock'
          when 'LL' then 'Library Cache Lock'
          when 'LM' then 'Library Cache Lock'
          when 'LN' then 'Library Cache Lock'
          when 'LO' then 'Library Cache Lock'
          when 'LP' then 'Library Cache Lock'
          when 'MM' then 'Mount Definition'
          when 'MR' then 'Media Recovery'
          when 'NA' then 'Library Cache Pin'
          when 'NB' then 'Library Cache Pin'
          when 'NC' then 'Library Cache Pin'
          when 'ND' then 'Library Cache Pin'
          when 'NE' then 'Library Cache Pin'
          when 'NF' then 'Library Cache Pin'
          when 'NG' then 'Library Cache Pin'
          when 'NH' then 'Library Cache Pin'
          when 'NI' then 'Library Cache Pin'
          when 'NJ' then 'Library Cache Pin'
          when 'NK' then 'Library Cache Pin'
          when 'NL' then 'Library Cache Pin'
          when 'NM' then 'Library Cache Pin'
          when 'NN' then 'Library Cache Pin'
          when 'NO' then 'Library Cache Pin'
          when 'NP' then 'Library Cache Pin'
          when 'NQ' then 'Library Cache Pin'
          when 'NR' then 'Library Cache Pin'
          when 'NS' then 'Library Cache Pin'
          when 'NT' then 'Library Cache Pin'
          when 'NU' then 'Library Cache Pin'
          when 'NV' then 'Library Cache Pin'
          when 'NW' then 'Library Cache Pin'
          when 'NX' then 'Library Cache Pin'
          when 'NY' then 'Library Cache Pin'
          when 'NZ' then 'Library Cache Pin'
          when 'PF' then 'Password File'
          when 'PI' then 'Parallel Slaves'
          when 'PR' then 'Process Startup'
          when 'PS' then 'Parallel Slave Synchronization'
          when 'QA' then 'Row Cache Lock'
          when 'QB' then 'Row Cache Lock'
          when 'QC' then 'Row Cache Lock'
          when 'QD' then 'Row Cache Lock'
          when 'QE' then 'Row Cache Lock'
          when 'QF' then 'Row Cache Lock'
          when 'QG' then 'Row Cache Lock'
          when 'QH' then 'Row Cache Lock'
          when 'QI' then 'Row Cache Lock'
          when 'QJ' then 'Row Cache Lock'
          when 'QK' then 'Row Cache Lock'
          when 'QL' then 'Row Cache Lock'
          when 'QM' then 'Row Cache Lock'
          when 'QN' then 'Row Cache Lock'
          when 'QO' then 'Row Cache Lock'
          when 'QP' then 'Row Cache Lock'
          when 'QQ' then 'Row Cache Lock'
          when 'QR' then 'Row Cache Lock'
          when 'QS' then 'Row Cache Lock'
          when 'QT' then 'Row Cache Lock'
          when 'QU' then 'Row Cache Lock'
          when 'QV' then 'Row Cache Lock'
          when 'QW' then 'Row Cache Lock'
          when 'QX' then 'Row Cache Lock'
          when 'QY' then 'Row Cache Lock'
          when 'QZ' then 'Row Cache Lock'
          when 'RT' then 'Redo Thread'
          when 'SC' then 'System Commit number'
          when 'SM' then 'SMON synchronization'
          when 'SN' then 'Sequence Number'
          when 'SQ' then 'Sequence Enqueue'
          when 'SR' then 'Synchronous Replication'
          when 'SS' then 'Sort Segment'
          when 'ST' then 'Space Management Transaction'
          when 'SV' then 'Sequence Number Value'
          when 'TA' then 'Transaction Recovery'
          when 'TM' then 'DML Enqueue'
          when 'TS' then 'Table Space (or Temporary Segment)'
          when 'TT' then 'Temporary Table'
          when 'TX' then 'Transaction'
          when 'UL' then 'User-defined Locks'
          when 'UN' then 'User Name'
          when 'US' then 'Undo segment Serialization'
          when 'WL' then 'Writing redo Log'
          when 'XA' then 'Instance Attribute Lock'
          when 'XI' then 'Instance Registration Lock'
       end
          as type
  from V$LOCKED_OBJECT A
       inner join V$SESSION B on A.SESSION_ID = B.SID
       inner join DBA_OBJECTS C on A.OBJECT_ID = C.OBJECT_ID
       inner join GV$LOCK L on B.SID = L.SID;

Keine Kommentare:

Kommentar veröffentlichen