Oracle中查看一个表是否被锁住

时间:2021-06-02 12:19:47

SELECT OBJECT_NAME,
       SESSION_ID SID,
       MACHINE,
       VS.MODULE,
       'ALTER   SYSTEM   KILL   SESSION   ''' || SESSION_ID || ', ' ||
       SERIAL# || '''; ' KILL_SESSION,
       VS.STATUS,
       VS.ACTION,
       SERIAL#,
       ORACLE_USERNAME,
       OS_USER_NAME
  FROM V$LOCKED_OBJECT VO, V$SESSION VS, ALL_OBJECTS AO
 WHERE VO.SESSION_ID = VS.SID
   AND AO.OBJECT_ID = VO.OBJECT_ID
   AND NVL(VS.ACTION, '   ') <> 'Service   Management '
 ORDER BY OBJECT_NAME, MACHINE, VS.MODULE;

 

这段代码可以找到非系统锁的表,并给出   KILL   SESSION语句。可以查到是那台机器,有什么程序锁的表.