oracle数据库,关于锁表

一。跟锁表相关的表

SELECT*FROMv$lock;
SELECT*FROMv$sqlarea;
SELECT*FROMv$session;
SELECT*FROMv$process;
SELECT*FROMv$locked_object;
SELECT*FROMall_objects;
SELECT*FROMv$session_wait;

二。查看锁表sql

1.

select c.sid, c.serial#, c.username, c.osuser, b.owner, b.object_name, a.locked_mode, p.spid
from v$locked_object a, dba_objects b, v$session c, v$process p
where a.object_id = b.object_id
and a.session_id = c.sid
and c.paddr = p.addr ;

2.   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 2021-01-07 11:13  ajax取个名字真难  阅读(62)  评论(0编辑  收藏  举报

导航