DBAsupport.com Forums - Powered by vBulletin
Results 1 to 8 of 8

Thread: Session ID

  1. #1
    Join Date
    Nov 2000
    Posts
    224

    How to get Session ID

    How can I get the session id of my currently connected session

  2. #2
    Join Date
    Feb 2001
    Posts
    290
    select userenv('sessionid') from dual;

    well Stestakov is having better idea than me , may be u can search on this in this web site itself


  3. #3
    Join Date
    Nov 2000
    Posts
    224
    The sessionid returned from userenv('sessioid') is not listed in the output of V$SESSION.

    SQL> select userenv('sessionid') from dual;

    USERENV('SESSIONID')
    --------------------
    18817

    SQL> select username,sid,serial# from v$session;

    USERNAME SID SERIAL#
    ------------------------------ ---------- ----------
    1 1
    2 1
    3 1
    4 1
    5 1
    6 1
    7 1
    PFIN 9 3284
    SPA 10 1490
    SPA 16 2298
    SPA 18 788

    USERNAME SID SERIAL#
    ------------------------------ ---------- ----------
    PROSPECTOR 19 975
    21 957
    SPA 22 480

    14 rows selected.



  4. #4
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    SELECT sid FROM v$mystat WHERE rownum=1;
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  5. #5
    Join Date
    Feb 2001
    Posts
    290
    select * from v$session
    where sid= (Select distinct sid from v$mystat);

  6. #6
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    Originally posted by mrvajrala
    select * from v$session
    where sid= (Select distinct sid from v$mystat);
    pretty costy query to get your sid

  7. #7
    Join Date
    Feb 2001
    Posts
    290
    Well I tried to get all my session info.. an it took 1 sec for me to get the output...

  8. #8
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    because you are the only user arnet you? your query uses an innecessary order by and subquery...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width