如何杀掉Oracle的Session
1个回答
展开全部
需要查询SID和SERIAL#,然后kill掉。
方法1、用sql语句
SHELL> sqlplus /nolog
SQL> conn /as sysdba
SQL> set head off
SQL> spool kill.txt
SQL> select ‘alter system kill session ‘ || ”” || a.SID || ‘,’ || a.SERIAL# || ””||’ ;’ from v$session a where a.STATUS = ‘ACTIVE' and osuser='alex';
SQL> spool off
SQL> exit
SHELL>sed -i ‘/^$/d’ ~/kill.txt
SHELL>sqlplus /nolog
SQL> conn /as sysdba
SQL> @kill.txt
SQL> exit
方法2、用proc
declare cursor mycur is
select b.sid,b.serial#
from v$locked_object a,v$session b
where a.session_id = b.sid group by b.sid,b.serial#;
begin
for cur in mycur
loop
execute immediate ( ‘alter system kill session ”’||cur.sid || ‘,’|| cur.SERIAL# ||”’ ‘);
end loop;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询