--过程一定义
create or replace procedure kill_session( p_sid in number,
p_serial# in number)
is
BEGIN
execute immediate '
alter system kill session ''' ||
to_char(p_sid,'999999')||','||
to_char(p_serial#,'999999')||'''';
END;
/
--过程二定义
create or replace procedure kill_session( p_sid in number,
p_serial# in number)
is
BEGIN
execute immediate '
alter system kill session ''' ||
to_char(p_sid,'999999')||','||
to_char(p_serial#,'999999')||''''||' immediate';
END;
/
--杀死特定用户的会话
declare
cursor finduser( p_username v$session.username%type)
is
select sid,serial#
from v$session
where username=p_username;
r_cursor finduser%rowtype;
begin
open finduser('SCOTT');
loop
fetch finduser into r_cursor;
kill_session(r_cursor.sid,r_cursor.serial#);
--dbms_output.put_line(r_cursor.sid);
--dbms_output.put_line(r_cursor.serial#);
exit when finduser%notfound;
end loop;
end;
/
|
|