Oralce 中查詢鎖表記錄以及解鎖

來源:互聯網
上載者:User

Oralce 中查詢鎖表記錄以及解鎖

先查詢那些表被鎖定了
 
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;

查詢出被鎖定的表的 sid 和serial# 然後kill
 
select b.username,b.sid,b.serial#,logon_time
 from v$locked_object a,v$session b
 where a.session_id = b.sid and sid in(
 select a.SESSION_ID
 from v$locked_object a,dba_objects b
 where b.object_id = a.object_id) order by b.logon_time

解鎖
 
alter system kill session '589,2693' immediate;(589 是sid,2693是serial)

另外作此操作的必須要有資料庫管理的許可權否則無法解鎖。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.