檢視處理Oracle中被鎖物件的SQL

ljm0211發表於2012-07-02

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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章