This discussion is archived
5 Replies Latest reply: Sep 8, 2010 4:33 AM by Ulfet Tanriverdiyev RSS

To find pid from sid

794905 Newbie
Currently Being Moderated
Hi all,

Plz tell hou to find pid (os level) for the respective sid..

want the query..plz

Thanks
  • 1. Re: To find pid from sid
    Anurag Tibrewal Guru
    Currently Being Moderated
    Hi,

    Join paddr of v$session with addr of v$process to get the pid (pid column of v$process)

    Regards
    Anurag
  • 2. Re: To find pid from sid
    orawiss Oracle ACE
    Currently Being Moderated
    SELECT P.SPID, S.SID, S.SERIAL#
    FROM V$PROCESS P, V$SESSION S
    WHERE P.ADDR = S.PADDR
    AND S.SID = 32505;
  • 3. Re: To find pid from sid
    rajeysh Guru
    Currently Being Moderated
    Show user info including os pid
    col "SID/SERIAL" format a10
    col username format a15
    col osuser format a15
    col program format a40
    select     s.sid || ',' || s.serial# "SID/SERIAL"
    ,     s.username
    ,     s.osuser
    ,     p.spid "OS PID"
    ,     s.program
    from     v$session s
    ,     v$process p
    Where     s.paddr = p.addr
    order      by to_number(p.spid)
    /
    reference: http://www.shutdownabort.com/dbaqueries/Administration_Session.php
  • 4. Re: To find pid from sid
    gjilevski1 Journeyer
    Currently Being Moderated
    Hi,

    You need to obtain SPID from v$SESSION and V$PROCESS.

    select spid, osuser, s.program from
    v$process p, v$session s where p.addr=s.paddr;


    Regards,
  • 5. Re: To find pid from sid
    Ulfet Tanriverdiyev Journeyer
    Currently Being Moderated
    Hope below info will be useful for you:


    Show all connected users

    select username,sid || ',' || serial# "ID",status,last_call_et "Last Activity"
    from v$session
    where username is not null
    order by status desc, last_call_et desc



    Time since last user activity

    select username,floor(last_call_et / 60) "Minutes",status
    from v$session
    where username is not null
    order by last_call_et



    Sessions sorted by logon time

    select      username,osuser,sid || ',' || serial# "ID",status,to_char(logon_time, 'hh24:mi dd/mm/yy') login_time,last_call_et
    from     v$session
    where     username is not null
    order     by login_time



    Show user info including os pid

    select     s.sid || ',' || s.serial# "SID/SERIAL",s.username,s.osuser,p.spid "OS PID",s.program
    from     v$session s,v$process p
    Where     s.paddr = p.addr
    order      by to_number(p.spid)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points