oracle解除被锁定的表的状态

 
select b.owner,b.object_name,a.session_id,a.locked_mode,c.serial#,c.sid||','||c.serial#
from v$locked_object a,dba_objects b ,v$session c
where b.object_id = a.object_id 
And a.session_id = c.sid

  

解除锁表
--alter system kill session 'sid,serial' immediate; 
--SID和Serial#共同确定一唯一的session。例如:
alter system kill session '99,123#' immediate; 

  

查询锁表原因:
select l.session_id sid,

       s.serial#,
       l.locked_mode,
       l.oracle_username,
       s.user#,
       l.os_user_name,
       s.machine,
       s.terminal,
       a.sql_text,
       a.action
  from v$sqlarea a, v$session s, v$locked_object l
where l.session_id = s.sid
   and s.prev_sql_addr = a.address
order by sid, s.serial#;

  

生成批量解锁sql:

select distinct * from 
(
select 'alter system kill session '''||l.session_id||','|| s.serial# ||''' immediate; ' kill
  from v$sqlarea a, v$session s, v$locked_object l
where l.session_id = s.sid
   and s.prev_sql_addr = a.address
order by sid, s.serial#
)

 

posted @ 2019-06-28 13:59  xtjatswc  阅读(1535)  评论(0编辑  收藏  举报