set serveroutput on declare v_sid v$session.sid%type; v_serial v$session.serial#%type; cursor killuser is select sid, serial# from v$session where username='HTPCBAK';--用户名大写 begin open killuser; fetch killuser into v_sid,v_serial; while killuser%found loop execute immediate 'alter system kill session '''||v_sid||','||v_serial||'''';--注意字符串的拼接 fetch killuser into v_sid,v_serial; end loop; close killuser; end; /
当我们执行以上操作后,发现被kill的会话还存在,是不是没有被终止掉?
如果我们继续使用被kill掉回话的‘HTPCBAK’用户进行其他操作时,被拒绝
推荐文章:
kill会话过程分析:http://blog.csdn.net/changyanmanman/article/details/7491295