oracle 数据库锁相关查询及操作

select a.object_name||'|'||b.session_id||'|'||c.serial#||'|'||c.program||'|'||c.username||'|'||c.command||'|'||c.machine||'|'||
c.lockwait from all_objects a,v$locked_object b,v$session c where a.object_id=b.object_id and c.sid=b.session_id;


alter system kill session '2022,5763';

 

 

 

SELECT    sn.username, m.SID,sn.SERIAL#, m.TYPE,
          DECODE (m.lmode,
                  0, 'None',
                  1, 'Null',
                  2, 'Row Share',
                  3, 'Row Excl.',
                  4, 'Share',
                  5, 'S/Row Excl.',
                  6, 'Exclusive',
                  lmode, LTRIM (TO_CHAR (lmode, '990'))
                 ) lmode,
          DECODE (m.request,
                  0, 'None',
                  1, 'Null',
                  2, 'Row Share',
                  3, 'Row Excl.',
                  4, 'Share',
                  5, 'S/Row Excl.',
                  6, 'Exclusive',
                  request, LTRIM (TO_CHAR (m.request, '990'))
                 ) request,
          m.id1, m.id2
     FROM v$session sn, v$lock m
    WHERE (sn.SID = m.SID AND m.request != 0)        
       OR (     sn.SID = m.SID                       
           AND m.request = 0
           AND lmode != 4
           AND (id1, id2) IN (
                         SELECT s.id1, s.id2
                           FROM v$lock s
                          WHERE request != 0 AND s.id1 = m.id1
                                AND s.id2 = m.id2)
          )ORDER BY id1, id2, m.request;

 

你可能感兴趣的:(oracle)