jeudi 25 avril 2013

Oracle : deleting multiple sessions with certain conditions (like machine=...)

Generate queries for deleting all sessions with certain conditions (like machine=...) :

SELECT

            'ALTER SYSTEM DISCONNECT SESSION  '''||s.sid||','||s.serial#||''' IMMEDIATE;'

FROM 
            gv$session s
            JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id


WHERE   

            s.type != 'BACKGROUND' and s.status='INACTIVE' ;




Other interesting conditions :


  • s.username : the username used to connect to the DB
  • s.schemaname : the name of the schema
  • s.status : ACTIVE/INACTIVE
  • s.osuser : the Windows/Linux/... username on the remote computer (the client)
  • s.machine : the name of the remote computer (the client)


Aucun commentaire:

Categories