1. 程式人生 > >Oracle查詢被鎖的表及解鎖方法

Oracle查詢被鎖的表及解鎖方法

v$lock req 查找 rom 方法 session lock acl oracle

1.用下列sql語句查詢操作不當引起鎖表的進程的SESSION_ID及USERNAME

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||’)’, 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;
假設查詢列表如下:

1XXXX U001 ……………………………………..

2XXXX U002 ……………………………………..

3XXXX U003 ……………………………………..

2.將SESSION_ID及USERNAME做為條件查找出serial#

select sid, serial# from v$session where sid=’1XXXX’ and username=’U001′;

假設查詢列表如下:

1XXXX adfadfadf

3.通過以上查詢知道了sid和 SERIAL#就可以開殺了
alter system kill session ‘1XXXX ,adfadfadf’;

Oracle查詢被鎖的表及解鎖方法