************************************************************************
* Description: Find session id when starting an Oracle database session
* Date: 02:27 PM EST, 03/26/2020
************************************************************************
<1> When starting an Oracle session via SQL*Plus or SQL*Developer, session id sometimes needed for tracing purpose:
|
|__ o. Following SQL is used to show the id of the current session:
|
|__ o. SYS_CONTEXT, within the SQL returns the value of parameter associated with the context namespace.
| You can use this function in both SQL and PL/SQL statements.
|
|__ o. USERENV, which is a built-in namespace provded by Oracle, and describes the metadata of current session.
|
|__ o. AUDSID, as a column within v$session, means the session being audited. This where clause ensures the session id is dedicated to this current session.
|
|__ SQL> select sid, program from v$session where audsid = SYS_CONTEXT('USERENV','sessionid');
Your Comments