首页 > 代码库 > Oracle锁表处理操作笔记

Oracle锁表处理操作笔记

--查看锁表进程SQL语句1:

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;

或者

SELECT b.owner,
       b.object_name,
       a.session_id,
       a.locked_mode
  FROM v$locked_object a, dba_objects b
 WHERE b.object_id = a.object_id;

---查看锁表进程SQL语句2:

SELECT *
  FROM v$session t1, v$locked_object t2
 WHERE t1.sid = t2.SESSION_ID;

或者

 SELECT b.username,
         b.sid,
         b.serial#,
         logon_time
    FROM v$locked_object a, v$session b
   WHERE a.session_id = b.sid
ORDER BY b.logon_time;

--查看数据库连接进程

SELECT sid, serial#, username,osuser FROM v$session; 

--杀掉锁的进程 sid,serial#

ALTER SYSTEM KILL SESSION sid,serial;

 

Oracle锁表处理操作笔记