Thursday, June 30, 2016

Query to find out online users

The following query is mainly intended to identify online users as batch jobs can be monitored via the Concurrent Manager.


SELECT c.SID, c.serial# ser, c.module, SUBSTR (c.program, 1, 10) program,
       c.last_call_et last_call, c.sql_hash_value, d.spid, c.process
  FROM v$session c, v$process d
 WHERE c.status = 'ACTIVE'           -- the session is running in the database
   AND c.last_call_et > 300           -- has been running for over 300 seconds
   AND c.paddr = d.addr
   AND c.lockwait IS NULL                       -- not waiting on a (row) lock
   AND (c.program LIKE 'f60%' OR c.program LIKE 'sqlplus%')-- only interesting programs