denrepo

OracleSessions

Generate kill statements for a user's sessions

Prompts for a username and prints one ALTER SYSTEM KILL SESSION per session, including the instance on RAC. Nothing is killed until you run the output.

Prompts for inputAll RAC instances

Not yet verified. How scripts are tested

ora-kill-gen.sql
1CLEAR COLUMNS2SET LINESIZE 120 PAGESIZE 0 TRIMOUT ON TAB OFF VERIFY OFF FEEDBACK OFF3 4SELECT 'ALTER SYSTEM KILL SESSION ''' || sid || ',' || serial# || ',@' || inst_id5       || ''' IMMEDIATE;  -- ' || status || ' ' || program AS kill_cmd6FROM gv$session7WHERE username = UPPER('&username')8  AND type = 'USER';9 10SET PAGESIZE 100 FEEDBACK ON

Save it as ora-kill-gen.sql and run it with SQL> @ora-kill-gen.

Open in denrepo

More Oracle scripts: Sessions