Skip to content

Instantly share code, notes, and snippets.

@aimtiaz11
Last active August 29, 2015 14:08
Show Gist options
  • Save aimtiaz11/7f2e9fc4d3ff2b0a9572 to your computer and use it in GitHub Desktop.
Save aimtiaz11/7f2e9fc4d3ff2b0a9572 to your computer and use it in GitHub Desktop.
SQL Script to Kill Oracle Database sessions

In order to kill database sessions, run the following scripts in SQL *Plus and then exit.

Replace SCHEMA_NAME with the name of your schema.

declare
  cursor c1 is
  SELECT s.sid, s.serial# as serial
  FROM v$session s, v$process p
  WHERE s.username = 'SCHEMA_NAME'
  AND p.addr(+) = s.paddr;
begin
  for rec in c1 loop
    execute immediate 'Alter System Kill Session '''|| rec.Sid
           || ',' || rec.Serial|| ''' IMMEDIATE';
  end loop;
end;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment