当前位置:网站首页>Oracle lock table query and unlocking method

Oracle lock table query and unlocking method

2022-04-23 13:40:00 Wangcai 2

View locked table information

select sess.sid,sess.serial#,
lo.oracle_username ' Login account ',lo.os_user_name ' Log in to your computer ', 
ao.object_name ' Locked table name ',lo.locked_mode ' Locked level '  
from v$locked_object lo,dba_objects ao,v$session sess 
where ao.object_id=lo.object_id and lo.session_id=sess.sid;

Kill the lock table process

alter system kill session '68,51';-- Respectively SID and SERIAL# Number 

View the table that caused the lock in the database SQL sentence

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;

版权声明
本文为[Wangcai 2]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230604301244.html