Oracle檢視被鎖物件及解鎖方法

landf發表於2012-03-09
1,檢視被鎖物件及鎖型別、鎖模式
SELECT S.SID SESSION_ID,
       S.USERNAME,
       DECODE (LMODE,
               0, ' None ',
               1, ' Null ',
               2, ' Row-S(SS) ',
               3, ' Row-X(SX) ',
               4, ' Share',
               5, 'S/Row-X (SSX) ',
               6, 'Exclusive ',
               TO_CHAR (LMODE))
          MODE_HELD,
       DECODE (REQUEST,
               0, ' None ',
               1, ' Null ',
               2, ' Row-S(SS) ',
               3, ' Row-X(SX) ',
               4, ' Share',
               5, 'S/Row-X (SSX) ',
               6, 'Exclusive ',
               TO_CHAR (REQUEST))
         MODE_REQUESTED,
       O.OWNER|| ' . ' || O.OBJECT_NAME|| '  ( ' || O.OBJECT_TYPE|| ' ) ' as OBJECT_NAME,
       S.TYPE LOCK_TYPE,
       L.ID1 LOCK_ID1,
       L.ID2 LOCK_ID2
  FROM V$LOCK L, SYS.DBA_OBJECTS O,V$SESSION S
 WHERE L.SID = S.SID AND L.ID1 = O.OBJECT_ID;

2,使用sid資訊檢視檢視V$SESSION,獲取sid,serial#資訊
select * from v$session where sid=?

3,通知會話使用者釋出rollback或commit命令結束事務,或強制結束會話
alter system kill session "sid,serial#";

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14359/viewspace-718112/,如需轉載,請註明出處,否則將追究法律責任。

相關文章