marți, 6 octombrie 2015

How to kill all the sessions of a user, from all the instances of a RAC

Shortly, connect as sys and run the following script:

begin
for objects in (select sid, serial#,inst_id from gv$session where username='USER_TO_KILL') loop
EXECUTE IMMEDIATE 'alter system kill session '''||objects.sid||','||objects.serial#||',@'||objects.inst_id||''''||' immediate';
end loop;
end;