oracle锁表查询处理

原文链接:https://blog.csdn.net/qq_38819293/article/details/86526696

--查看被锁表信息
SQL > select sess.sid,sess.serial#, lo.oracle_username,lo.os_user_name, ao.object_name,lo.locked_mode  from v$locked_object lo,dba_objects ao,v$session sess where ao.object_id=lo.object_id and lo.session_id=sess.sid;

 

 --杀掉锁表进程
SQL > alter system kill session '68,51';--分别为SID和SERIAL#号

--查看数据库引起锁表的SQL语句 
SELECT A.USERNAME,
       A.MACHINE,
       A.PROGRAM,
       A.SID,
       A.SERIAL#,
       A.STATUS,
       C.PIECE,
       C.SQL_TEXT
  FROM V$SESSION A, V$SQLTEXT C
 WHERE A.SID IN (SELECT DISTINCT T2.SID
                   FROM V$LOCKED_OBJECT T1, V$SESSION T2
                  WHERE T1.SESSION_ID = T2.SID)
   AND A.SQL_ADDRESS = C.ADDRESS(+)
 ORDER BY C.PIECE;

posted on 2020-08-07 11:12  yunjie_miao  阅读(341)  评论(0编辑  收藏  举报