How do we identify a session in Oracle GV$SESSION view?

4.1k Views Asked by At

I am trying to understand what is the minimal set of parameters to uniquely identify a session in GV$SESSION. I have seen a few online examples there AUDSID, SID, and INST_ID are used, I am trying to understand why?

4

There are 4 best solutions below

0
GMB On

For a given instance, a session is uniquely identified by its SID and its SERIAL#, as explained in the documentation:

SID: Session identifier

SERIAL#: Session serial number. Used to uniquely identify a session's objects. Guarantees that session-level commands are applied to the correct session objects if the session ends and another session begins with the same session ID.

You can add INST_ID to that if you are running a RAC environment.

0
Alexey S. Larionov On

It's a pair of values SID and SERIAL#

Description on both of them in docs explains why:

SID

  • Session identifier

SERIAL#

  • Session serial number. Used to uniquely identify a session's objects. Guarantees that session-level commands are applied to the correct session objects if the session ends and another session begins with the same session ID.
0
pifor On

SID and SERIAL# are enough in V$SESSION for single instance database.

SID, SERIAL#, INST_ID are enough for RAC cluster database in GV$SESSION.

NB: no need to use GV$SESSION if not RAC.

0
Osamazx On

GV$session vs V$session is used on standalone database, an gv$session (g=global) is used mostly on RAC environments.

AUDSID is a unique identifier for the session and is used in sys.aud$ , as the SESSIONID column. It is the leading column of the only index on sys.aud$

INST_ID column displays the instance number from which the associated V$ view information was obtained

The best way to understand both of them to refer to Oracle documentation and understand what each column do,

https://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_2088.htm#REFRN30223