Script exemplo para remover processos em bloqueio ou sem uso - Deadlock

 

--// Gera  script das conexões inativas

SELECT
                'alter system kill session '''||s.sid||','||s.serial#||''';' "Kill Statement"
FROM
                v$session s , v$process p
WHERE
                               s.paddr = p.addr
                AND s.username IS NOT NULL
                AND s.last_call_et > 3600
                AND s.status='INACTIVE';
               

--// Gera  script de um usuário específico

SELECT
                'alter system kill session '''||s.sid||','||s.serial#||''';' "Kill Statement"
FROM
                v$session s , v$process p
WHERE
                               s.paddr = p.addr
                AND s.username IS NOT NULL
                AND s.OSUSER LIKE '%lgaldino%';
 

--// Lista os processos a partir de um computador específico


SELECT
                *
FROM
                v$session s , v$process p
WHERE
                               s.paddr = p.addr
                AND s.username IS NOT NULL
                AND s.machine LIKE '%FINA%';
 


--// Gera script a partir de um computador específico


SELECT
                'alter system kill session '''||s.sid||','||s.serial#||''';' "Kill Statement"
FROM
                v$session s , v$process p
WHERE
                               s.paddr = p.addr
                AND s.username IS NOT NULL
                AND s.status='INACTIVE'
AND  MACHINE = 'DOMINIO\USUARIO';