Oracle檢查死結的sql

來源:互聯網
上載者:User
 檢查死結的sql語句

1. 

SELECT SID, DECODE(BLOCK, 0, 'NO', 'YES' ) BLOCKER, DECODE(REQUEST, 0, 'NO','YES' ) WAITER
FROM V$LOCK 
WHERE REQUEST > 0 OR BLOCK > 0 
ORDER BY block DESC;

2. 

SELECT bs.username "Blocking User", bs.username "DB User", 
        ws.username "Waiting User", bs.sid "SID", ws.sid "WSID", 
        bs.serial# "Serial#", 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#", 
        ws.serial# "WSerial#", 
        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, 
        DECODE (hk.BLOCK, 
                0, 'NOT Blocking', /* Not blocking any other processes */ 
                1, 'Blocking', /* This lock blocks other processes */ 
                2, 'Global', /* This lock is global, so we can't tell */ 
                TO_CHAR (hk.BLOCK) 
                ) blocking_others 
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(+) 
AND (bs.username IS NOT NULL) 
AND (bs.username <> 'SYSTEM') 
AND (bs.username <> 'SYS') 
ORDER BY 1;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.