Pega todas as sessoes que estão bloqueando objetos, menos as estão aguardando em lock wait.
1 2 3 4 5 6 | --"Usuários com objetos bloqueados via regra de derrubar" select distinct 'ALTER SYSTEM KILL SESSION '|| ''''||vs.sid||','||vs.serial#||',@'||vs.inst_id||''' IMMEDIATE; --'||vs.osuser||' '||vs.client_info||' '||vs.program from gv$session vs inner join GV$LOCKED_OBJECT vl on vl.session_id = vs.sid and vs.inst_id = vl.inst_id where (select count(sid) from gv$session where lockwait is not null) > 1 and vs.sid||vs.serial#||vs.inst_id not in (select sid||serial#||inst_id from gv$session where lockwait is not null); |