Skip to content

Instantly share code, notes, and snippets.

@vitaminac
Created February 15, 2019 10:32
Show Gist options
  • Save vitaminac/1253421baab16f55015be1d8d5c9e1f1 to your computer and use it in GitHub Desktop.
Save vitaminac/1253421baab16f55015be1d8d5c9e1f1 to your computer and use it in GitHub Desktop.
script to kill all session in oracle
BEGIN
FOR R IN (
SELECT
SID,
SERIAL#
FROM V$SESSION
WHERE USERNAME IS NOT NULL AND SID <> (
SELECT sys_context('USERENV', 'SID')
FROM DUAL))
LOOP EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' || R.SID || ',' || R.SERIAL# || '''';
END LOOP;
END;
DISCONNECT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment