SET linesize 250
COL spid FOR A6
COL logon_time FOR A21
COL username FOR A10
COL command FOR A60
COL sql_text FOR A75
SELECT s.inst_id, p.spid, TO_CHAR(logon_time, 'YYYY/MM/DD HH24:MI:SS') logon_time, s.username,
'ALTER SYSTEM KILL SESSION ''' || s.sid || ',' || s.serial# || ',@' || s.inst_id || ''' IMMEDIATE;' command,
substr(a.sql_text, 0, 75) sql_text, a.sql_id
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
JOIN gv$sqlarea a ON a.sql_id = s.sql_id AND s.status = 'ACTIVE' AND a.inst_id = s.inst_id
WHERE s.TYPE != 'BACKGROUND' and p.program not like '%PZ%';
SELECT sql_text FROM gv$sqlarea WHERE sql_id = '&sql_id';