ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 查看处理Oracle中被锁对象的SQL

查看处理Oracle中被锁对象的SQL

原创 Linux操作系统 作者:ljm0211 时间:2012-07-02 11:11:09 0 删除 编辑

SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
ORDER BY sid, s.serial# ;

alter system kill session '679,14748';


select 'alter system kill session '''||sid||','||serial#||''';' from v$session where (sid,serial#) in (SELECT l.session_id sid, s.serial#
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid) and object_name='PRPJPAYREFREC') ;

alter system kill session '547,46429';
alter system kill session '565,58055';
alter system kill session '735,26695';
alter system kill session '797,52758';

select p.*,s.* from v$session s,v$process p where sid=625 and s.paddr=p.addr
select event,seconds_in_wait,state from v$session_wait where sid=859;


SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid and s.sid=859
ORDER BY sid, s.serial# ;

select /*+ rule */ lpad('--',decode(b.block,1,0,4))||s.username user_name,
b.type,o.owner||'.'||o.object_name object_name,
s.sid,s.serial#,decode(b.REQUEST,0,'BLOCKED','WAITING') status
FROM dba_objects o,v$session s,v$lock v,v$lock b
where v.ID1=o.object_id and v.SID=s.sid
and v.SID=b.SID and (b.BLOCK=1 or b.REQUEST>0)
and v.TYPE='TM'
order by b.ID2,v.ID1,user_name desc;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11411056/viewspace-734306/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-05-14

  • 博文量
    272
  • 访问量
    436725