-
How to find SID
I know V$SESSION holds the SID info; but I have several sessions open for the User SCOTT; and I'm currently working on a particular session with some transaction. How can I find out what is the SID of this current session I am working on, assuming there is more than one SCOTT session open.
Can anyone pls tell me.
Last edited by Vipassana; 07-09-2004 at 03:11 AM.
-
For your current session:
select * from v$session
where audsid=SYS_CONTEXT ('USERENV', 'SESSIONID')
-
Originally posted by DaPi
For your current session:
select * from v$session
where audsid=SYS_CONTEXT ('USERENV', 'SESSIONID')
Thanks bud.. that's exactly what I needed.
BTW, what does "audsid" mean? I mean how is it different from sid?
Last edited by Vipassana; 07-09-2004 at 03:52 AM.
-
Originally posted by DaPi
For your current session:
select * from v$session
where audsid=SYS_CONTEXT ('USERENV', 'SESSIONID')
Sorry, just realized this didn't help me. I got two rows for this query:
SQL> select sid from v$session
2 where audsid=SYS_CONTEXT ('USERENV', 'SESSIONID');
SID
----------
214
243
How to know which is the one I am working on?
-
AUDSID = Auditing session ID
It is a Oracle-type sequence allocated to sessions: so always increasing, never reused. (SID numbers are reused).
I've seen this behaviour (in 8.1.7) with Parallel Query - it will "spawn" additional sessions(?) - different SID, same AUDSID - to run several parallel processes. Under some circumstances (which? - I have no idea) these sessions remain in v$session after the query is finished.
- 0 - 0 - 0 -
I've just realised that the above two paragraphs are contradictory in regard to reuse of AUDSID's. Perhaps some kind of distinction needs to be made between sessions and sub-sessions? I'm getting out of my depth here.
Last edited by DaPi; 07-09-2004 at 04:32 AM.
-
SELECT sid FROM v$mystat WHERE ROWNUM < 2;
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
Originally posted by jmodic
SELECT sid FROM v$mystat WHERE ROWNUM < 2;
Yes, this will fetch one row; but what does that mean anyway? I mean how can this justify that that's the SID of the current session?
-
Originally posted by Vipassana
. . . how can this justify that that's the SID of the current session?
That's how it's defined: http://download-west.oracle.com/docs...h394.htm#30323
-
I thk you missed the Q. The question was - "How can we say that the SID of the least ROWNUM is the correct one, when there are more than one SIDs for the same session" !!!
-
If you look in v$mystat, do you see more than one SID?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|