码迷,mamicode.com
首页 > 数据库 > 详细

Oracle查询被锁的表及解锁方法

时间:2017-05-13 17:02:10      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:har   name   cts   sid   serial   objects   alt   row   sys   

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查询被锁的表及解锁方法

标签:har   name   cts   sid   serial   objects   alt   row   sys   

原文地址:http://www.cnblogs.com/gaopengpy/p/6849217.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!