Wednesday, April 27, 2011

Getting all sessions for Oracle Server in a query? Easy to do

Easy to do:
select s.username, s.osuser, s.status, lockwait,
       s.program, s.machine, s.logon_time,
       p.program process_program, si.physical_reads, si.block_gets, si.consistent_gets,
       si.block_changes, si.consistent_changes, s.process, p.spid,
       p.pid, s.serial#, si.sid
from   sys.v_$sess_io si, sys.v_$session s, sys.v_$process p
where  s.username is not null
and    si.sid(+) = s.sid
and    p.addr(+) = s.paddr
order by s.status, si.consistent_gets + si.block_gets desc
Results:
The result gives us a list of sessions in the current server.

No comments:

Post a Comment