【翻译自mos文章】怎么获得Oracle Database 12c中的audit session id

时间:2021-01-16 21:31:47


怎么获得Oracle Database 12c中的audit session id
来源于:
How to obtain audit session ID in Oracle Database 12c (文档 ID 2016845.1)

适用于:
Oracle Database - Enterprise Edition - Version 12.1.0.2 and later
Information in this document applies to any platform.

解决方案:
在Oracle database 12c之前,audit session id 是基于AUDSES$这个序列的,在oracle  database 12c中,只要Unified Auditing被关闭,audit session id 依然是基于AUDSES$这个序列的

SQL> conn vlad/vlad
Connected.

SQL> select value from v$option where parameter='Unified Auditing';

VALUE
----------------------------------------------------------------
FALSE

SQL> select last_number from dba_sequences where sequence_name='AUDSES$';

LAST_NUMBER
-----------
290016

SQL> select audsid from v$session where username='VLAD';

AUDSID
----------
290016

SQL> select SYS_CONTEXT('USERENV', 'SESSIONID') from dual;

SYS_CONTEXT('USERENV','SESSIONID')
--------------------------------------------------------------------------------
290016


Unified Auditing被启用,the audit session ID不在是基于序列的了,the audit session ID是随机生成的。

SQL> select value from v$option where parameter='Unified Auditing';

VALUE
----------------------------------------------------------------
TRUE

SQL> conn vlad/vlad
Connected.
SQL> select sys_context('userenv','UNIFIED_AUDIT_SESSIONID') from dual;

SYS_CONTEXT('USERENV','UNIFIED_AUDIT_SESSIONID')
--------------------------------------------------------------------------------
137315960

SQL> conn vlad/vlad
Connected.
SQL> select sys_context('userenv','UNIFIED_AUDIT_SESSIONID') from dual;

SYS_CONTEXT('USERENV','UNIFIED_AUDIT_SESSIONID')
--------------------------------------------------------------------------------
2041291097

SQL> conn vlad/vlad
Connected.
SQL> select sys_context('userenv','UNIFIED_AUDIT_SESSIONID') from dual;

SYS_CONTEXT('USERENV','UNIFIED_AUDIT_SESSIONID')
--------------------------------------------------------------------------------
1706600580