您好,欢迎访问一九零五行业门户网

Oracle数据库查询对象是否被锁定及解锁

oracle数据库对象是否被锁定查询sql及解锁过程sql详见下面:
oracle数据库对象是否被锁定查询sql及解锁过程sql详见下面:
--查询当前用户下被锁的对象
select b.object_name, b.owner, c.sid,c.serial#,c.osuser, c.machine, c.terminal
  from v$locked_object a, dba_objects b, v$session c
 where a.object_id = b.object_id
  and a.session_id = c.sid
  and c.status='inactive'
  and c.type='user'
  order by 1;
--解锁语句 
declare
  v_sql varchar2(500);
  cursor c_session is
    select b.object_name,
        b.owner,
        c.sid as session_id,
        c.serial# as serial#,
        c.osuser,
        c.machine,
        c.terminal
    from v$locked_object a, dba_objects b, v$session c
    where a.object_id = b.object_id and a.session_id = c.sid
      and c.status = 'inactive' and c.type = 'user'
    order by 1;
begin
  for get_session in c_session
    loop
      begin
        v_sql:='alter system kill session '''||get_session.session_id||','||get_session.serial#||''' immediate';
        execute immediate v_sql;
      exception
        when others then
          null;
      end;
    end loop;
end;
/
linux-6-64下安装oracle 12c笔记
rhel6.4_64安装单实例oracle 12cr1
oracle 12c新特性之翻页查询
解读 oracle 12c 的 12 个新特性
本文永久更新链接地址:

其它类似信息

推荐信息