Oracle Kill Sessions

Disconnect sessions:

select * from v$session; --single node
select * from gv$session; --RAC, multi-node

alter system kill session 'sid,serial#';


BEGIN
  FOR c IN (
    SELECT s.inst_id,
           s.sid,
           s.serial#,
           p.spid,
           s.username,
           s.program,
           s.machine,
           s.process,
           s.status,
           s.schemaname
    FROM   gv$session s
           JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
    WHERE  s.type != 'BACKGROUND' and s.USERNAME='SOME USER NAME'
  )
  LOOP
      EXECUTE IMMEDIATE 'alter system kill session ''' || c.sid || ',' || c.serial# || '''';
  END LOOP;
END;


Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout

Locks held on Oracle for hours after sessions abnormally terminated by node failure