查锁与kill进程

 查看数据库锁
select t2.sid,t2.serial# session的ID号,t2.username,t2.schemaname,t2.machine,t2.program,
    t4.object_name,t2.logon_time,t3.piece sql编号,t3.sql_text
    from v$locked_object t1,v$session t2,v$sqltext t3,dba_objects t4
    where t1.session_id=t2.sid
    and t2.sql_address=t3.address
and t1.object_id=t4.object_id
  order by t2.sid,t4.object_name,t3.piece;
 
 
  select 'alter system kill session'||''''||m.sid||','||sn.serial#||''''||';'
from v$session sn,v$lock m
where sn.sid=m.sid
and m.request=0 and lmode!=4
 and (id1,id2) in
  (select s.id1,s.id2 from v$lock s
    where request!=0
       and s.id1=m.id1
       and s.id2=m.id2);

 

你可能感兴趣的:(sql)