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?
How do we identify a session in Oracle GV$SESSION view?
4.1k Views Asked by confucius_007 AtThere are 4 best solutions below
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.
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.
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
For a given instance, a session is uniquely identified by its
SIDand itsSERIAL#, as explained in the documentation:You can add
INST_IDto that if you are running a RAC environment.