关于数据库:Oracle锁表解决

28次阅读

共计 622 个字符,预计需要花费 2 分钟才能阅读完成。

查问锁表记录

select object_name,
       l.oracle_username,
       machine,
       s.sid,
       s.serial#,
       l.locked_mode,
       lo.ctime,
       lo.block,
       lo.type
from v$locked_object l,
     dba_objects o,
     v$session s,
     v$lock lo
where l.object_id = o.object_id
  and l.session_id = s.sid
  and s.sid = lo.sid;

查问锁表语句

SELECT A.USERNAME,
       A.MACHINE,
       A.PROGRAM,
       A.SID,
       A.SERIAL#,
       A.STATUS,
       C.PIECE,
       C.SQL_TEXT,
       lo.lmode,
       lo.ctime,
       lo.block,
       lo.type,
       l.locked_mode
FROM V$SESSION A,
     V$SQLTEXT C,
     v$lock lo,
     v$locked_object l
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 (+)
  and A.sid = lo.sid
  and A.sid = l.session_id
ORDER BY C.PIECE;

kill 会话

alter system kill session 'SID, SERIAL';

正文完
 0