I have a script to kill all sessions in Oracle:
declare
begin
for rec in (
SELECT username,machine,sid,serial#,inst_id from gv$session where type <> 'BACKGROUND'
and sid <> (select sys_context('userenv','sid') from dual) and status <> 'KILLED'
and username not in ('SYSRAC','SYS')
)
loop
execute immediate 'alter system disconnect session '''|| rec.sid|| ',' || rec.serial# || ',@' ||rec.inst_id||''' immediate';
end loop;
end;
/
Once a month I need kill all session before execute several scripts to add/remove/modify columns, grants and revokes, create new objects, drop objects etc..
This database usually has more than 2000 connections and when I execute this script it takes from 15 to 20 minutes to kill all sessions. How can I execute this script in parallel and kill all sessions faster?
question from:
https://stackoverflow.com/questions/65887705/oracle-how-to-execute-this-script-in-parallel 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…