Thursday, August 13, 2015

Oracle : Script to Display detailed information about the current user's session

def aps_prog    = 'mysess.sql'
 def aps_title   = 'Session  Info'
 col "Session Info" form A80

 select 'Sid, Serial#, Aud sid : '|| s.sid||' , '||s.serial#||' , '||
        s.audsid||chr(10)|| 'DB User / OS User : '||s.username||
        '   /   '||s.osuser||chr(10)|| 'Machine - Terminal : '||
        s.machine||'  -  '|| s.terminal||chr(10)||
  'OS Process Ids : '||
        s.process||' (Client)  '||p.spid||' (Server)'|| chr(10)||
        'Client Program Name : '||s.program "Session Info"
   from v$process p,v$session s
  where p.addr = s.paddr
   and s.audsid = userenv('SESSIONID')
/

No comments:

Post a Comment