oracle鎖表與解表

查看鎖表進程SQL語句1: html

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: session

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';
另外附上鎖定一個表的語句:
LOCK TABLE tablename IN EXCLUSIVE MODE;將鎖定整個表oracle

 

批量解鎖oop

declare cursor mycur is
select b.sid,b.serial#
  from v$locked_object a,v$session b
  where a.session_id = b.sid group by b.sid,b.serial#;
 
 
begin
  for cur in mycur
    loop  
     execute immediate ( 'alter system  kill session  '''||cur.sid || ','|| cur.SERIAL# ||''' ');
     end loop;
 
end;

 

來自:https://blog.csdn.net/tall913/article/details/7963841ui

https://www.cnblogs.com/xiaohaizhuimeng/p/6543028.htmlspa

相關文章
相關標籤/搜索