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;

查看锁表进程SQL语句2:
select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID;

杀掉锁表进程:
如有记录则表示有lock,记录下SID和serial# ,将记录的ID替換下面的738,1429,即可解除LOCK
alter system kill session '738,1429';

查看Oracle正在执行的SQL语句:

select osuser,program,username,schemaname,B.cpu_time,status,B.sql_text

from v$session A

         left join v$sql B on A.sql_address = B.address

         and A.sql_hash_value = B.hash_value

posted @ 2015-10-30 20:20  moonandstar08  阅读(266)  评论(0编辑  收藏  举报