find out what SID and SERIAL#  i am 10g when i connect

Jayesh Acharya
Jayesh Acharya used Ask the Experts™
on
is there a simple way for me to know what
sid / serial # i am when i connect to oracle.

Currently The same user id will connect a few times and will connect using the same program

I am really trying to find out if I can get the information from sys.v_$session, but i want it for the session I am currently connected to.

I was going to record this information in a log, so that if I have an issue with a process that was developed, I would be able to quickly look for the SID and Serial# to use the ALTER SYSTEM KILL SESSION '$SID,&SERIAL' command.

Any help would be apprecieated ...

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Commented:
SID:    select sys_context('USERENV','SID') from dual;
Top Expert 2009
Commented:
Session ID:  select sys_context('USERENV','SESSIONID') from dual;
Top Expert 2009

Commented:
You may also have a v$mystat and v$sesstat view, depending on which catalog views / synonyms exist in your db.

http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2098.htm
Hi,

Try the below query to get your current sid and serial#.

SQL> select sid, serial# from V$session where sid = (select distinct sid from V$mystat);

       SID    SERIAL#
---------- ----------
       136      52249

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial