Useful oracle session info


set lines 1000 pages 200

break on inst_id skip 1
col sid format 9999
col serial# format 999999
col username format a10
col Command format a15
col machine format a15
col os_user format a15
col program format a35
col logontime format a17
col ospid format a10
col event format a55
col sql_text format a75

SELECT  a.inst_id, 
        a.sid, 
        a.serial#,  
        b.spid ospid,
        TO_CHAR(logon_time,'dd-Mon-rr hh24:mi') LogonTime, 
        lower(a.username) username, 
        lower(a.machine) machine, 
        lower(status) status, 
        rpad(lower(osuser),15,' ') OS_User, 
            lower(a.program) program,
        decode(command,2,'INSERT',3,'SELECT',6,'UPDATE',7,'DELETE',47,'PL/SQL     
                        Execute',97,'CREATE PACKAGE BODY',94,'CREATE  
                        PACKAGE',21,'CREATE VIEW', 44, 'COMMIT' , 45, 'ROLLBACK'  
                        ,49,'ALTER SYSTEM',85,'TRUNCATE TABLE',command)  Command,
        event,
        SECONDS_IN_WAIT,
        BLOCKING_SESSION,
        BLOCKING_SESSION_STATUS
FROM gv$session a, gv$process b
WHERE a.inst_id = b.inst_id
  and a.paddr = b.addr
  --and lower(a.program)  like 'sql%'
  --AND a.username = 'STATS_PROC'
  --and status ='ACTIVE'
  --AND a.username is not null 
  --and b.spid=10610
  --and lower(a.program)='jdbc thin client'
  --and a.inst_id=1
  --and lower(status) <> 'inactive'
  --and A.username = 'SYS'
  --and a.sid=1047 
order by a.inst_id, a.username, sid;

Comments

Popular posts from this blog

Recover Standby database from ORA-00332: archived log is too small

Check Active Dataguard Replication Status

Top CPU consuming oracle sessions