首页 > 数据库 > Oracle > 无脑批量kill session(转载)
单实例无脑批量kill session
场景:测试或预生产产生大量死锁时,采取无脑批量kill session操作脚本。
备注:小工具备录一下
单实例无脑批量kill session declare cursor mycur is select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time; newcount number; begin for cur in mycur loop select count(1) into newcount from v$locked_object a,v$session b where a.session_id = b.sid and b.sid=cur.sid and b.serial#=cur.SERIAL# order by b.logon_time; if newcount>=1 then execute immediate ( 'alter system kill session '''||cur.sid || ','|| cur.SERIAL# ||''' '); end if; end loop; end;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26442936/viewspace-2690943/ ,如需转载,请注明出处,否则将追究法律责任。