Oracle查锁并解锁

1).


select LOCK_INFO.OWNER || '.' || LOCK_INFO.OBJ_NAME as "已鎖物件名稱",  --物件名稱(已經被鎖住)     
       LOCK_INFO.SUBOBJ_NAME as "已鎖子物件名稱",     -- 子物件名稱(已經被鎖住)  
       SESS_INFO.MACHINE as "機器名稱",     -- 機器名稱                
       LOCK_INFO.SESSION_ID as "會話ID",    -- 會話SESSION_ID          
       SESS_INFO.SERIAL# as "會話SERIAL#",     -- 會話SERIAL#             
       SESS_INFO.SPID as "OS系統的SPID",     -- OS系統的SPID        
       (SELECT INSTANCE_NAME FROM V$INSTANCE) "實例名SID", --實例名SID         
       LOCK_INFO.ORA_USERNAME as "ORACLE用戶",     -- ORACLE系統用戶名稱      
       LOCK_INFO.OS_USERNAME as "OS用戶",     -- 作業系統用戶名稱        
       LOCK_INFO.PROCESS as "進程編號",     -- 進程編號                
       LOCK_INFO.OBJ_ID as "對象ID",      -- 對象ID                  
       LOCK_INFO.OBJ_TYPE as "對象類型",     -- 對象類型                
       SESS_INFO.LOGON_TIME as "登錄時間",     -- 登錄時間                
       SESS_INFO.PROGRAM as "程式名稱",     -- 程式名稱                
       SESS_INFO.STATUS as "會話狀態",      -- 會話狀態                
       SESS_INFO.LOCKWAIT as "等待鎖",      -- 等待鎖                  
       SESS_INFO.ACTION as "動作",      -- 動作                    
       SESS_INFO.CLIENT_INFO as "客戶資訊"     -- 客戶資訊                
  from (select obj.OWNER                as OWNER,
               obj.OBJECT_NAME          as OBJ_NAME,
               obj.SUBOBJECT_NAME       as SUBOBJ_NAME,
               obj.OBJECT_ID            as OBJ_ID,
               obj.OBJECT_TYPE          as OBJ_TYPE,
               lock_obj.SESSION_ID      as SESSION_ID,
               lock_obj.ORACLE_USERNAME as ORA_USERNAME,
               lock_obj.OS_USER_NAME    as OS_USERNAME,
               lock_obj.PROCESS         as PROCESS
          from (select *
                  from all_objects
                 where object_id in (select object_id from v$locked_object)) obj,
               v$locked_object lock_obj
         where obj.object_id = lock_obj.object_id) LOCK_INFO,
       (select SID,
               SERIAL#,
               LOCKWAIT,
               STATUS,
               (select spid from v$process where addr = a.paddr) spid,
               PROGRAM,
               ACTION,
               CLIENT_INFO,
               LOGON_TIME,
               MACHINE
          from v$session a) SESS_INFO
 where LOCK_INFO.SESSION_ID = SESS_INFO.SID
order by  LOCK_INFO.SESSION_ID;

 

2).
select sql_text
  from v$sqltext
 where address in (select sql_address from v$session where sid = &sid)
 order by piece;
3).
ALTER SYSTEM KILL SESSION '會話ID,會話SERIAL#';
4).
kill -9 OS系統的SPID
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值