Kill all blocking Session

SELECT    'ALTER SYSTEM KILL SESSION '''

       || s.sid

       || ','

       || s.serial#

       || ''' IMMEDIATE;'

          AS ddl

  FROM v$session s

 WHERE s.blocking_session IS NOT NULL AND s.username LIKE 'SCOTT';


Output:

ALTER SYSTEM KILL SESSION '219,58809' IMMEDIATE;

ALTER SYSTEM KILL SESSION '2092,55113' IMMEDIATE;

ALTER SYSTEM KILL SESSION '2106,1395' IMMEDIATE;

ALTER SYSTEM KILL SESSION '2270,64683' IMMEDIATE;

ALTER SYSTEM KILL SESSION '3420,44703' IMMEDIATE;

ALTER SYSTEM KILL SESSION '4248,39077' IMMEDIATE;

Comments