Oracle查看锁表及解锁办法
Posted 停雨在心
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle查看锁表及解锁办法相关的知识,希望对你有一定的参考价值。
-- 查看被锁表信息
SELECT
L.SESSION_ID SID,
S.SERIAL#,
L.LOCKED_MODE,
L.ORACLE_USERNAME,
S.USER#,
L.OS_USER_NAME,
S.MACHINE,
S.TERMINAL,
A.SQL_TEXT,
A.ACTION
FROM
V$SQLAREA A,
V$SESSION S,
V$LOCKED_OBJECT L
WHERE
L.SESSION_ID = S.SID
AND S.PREV_SQL_ADDR = A.ADDRESS
ORDER BY
SID,
S.SERIAL#;
-- 杀掉锁表进程,KILL SESSION 两个值要换掉 分别为SID和SERIAL#号
ALTER SYSTEM KILL SESSION \'702, 23419\';
本文来自博客园,作者:停雨在心,转载请注明原文链接:https://www.cnblogs.com/ArtherLee/p/17433526.html
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查看锁表及解锁办法的主要内容,如果未能解决你的问题,请参考以下文章