Saturday, 4 July 2015

Here is the best script for killing sessions in Oracle, just run the script and copy/paste the output to kill sessions.

select ses.USERNAME,
    substr(MACHINE,1,10) as MACHINE,
    substr(module,1,25) as module,
    status,
    'alter system kill session '''||SID||','||ses.SERIAL#||''';' as kill
from v$session ses LEFT OUTER JOIN v$process p ON (ses.paddr=p.addr)
where schemaname <> 'SYS'
    and not exists
    (select 1
        from DBA_ROLE_PRIVS
        where GRANTED_ROLE='DBA'
            and schemaname=grantee)
    and machine!='yourlocalhostname'
order by LAST_CALL_ET desc;


Thanks.

No comments:

Post a Comment