手动kill掉inactive session的一个存储过程

CREATE OR REPLACE PROCEDURE kill_processes IS
v_c_kill varchar2(80);
BEGIN
/*  WARNING: If you use MTS (Shared Server) do not kill Shared      server processes* /
   FOR i IN (select sid,serial# from v$session where status='INACTIVE') LOOP
   V_c_kill := 'ALTER SYSTEM KILL SESSION ' ||''''||i.sid||','||i.serial#||'''';
   execute immediate v_c_kill;
   END LOOP;
END kill_processes;



set serveroutput on
set linesize 10000
variable x number;
begin
   DBMS_OUTPUT.enable(100000);  
   dbms_job.submit(:x,'kill_processes;',sysdate,'sysdate+2/24');
   commit;
   dbms_output.put_line(TO_char(:x));
end;

你可能感兴趣的:(手动kill掉inactive session的一个存储过程)