USERENV(OPTION) 返回当前的会话信息.

  OPTION='ISDBA'若当前是DBA角色,则为TRUE,否则FALSE.

  OPTION='LANGUAGE'返回数据库的字符集.

  OPTION='SESSIONID'为当前会话标识符.

  OPTION='ENTRYID'返回可审计的会话标识符.

  OPTION='LANG'返回会话语言名称的ISO简记.

  OPTION='INSTANCE'返回当前的实例.

  OPTION='terminal'返回当前计算机名

  SELECT USERENV('LANGUAGE') FROM DUAL;

 

 

--当前SID

select distinct sid from v$mystat;

select sid from v$session where audsid = userenv('SESSIONID');

 

2、返回系统会话信息sys_context

  select

  SYS_CONTEXT('USERENV','TERMINAL') terminal,

  SYS_CONTEXT('USERENV','LANGUAGE') language,

  SYS_CONTEXT('USERENV','SESSIONID') sessionid,

  SYS_CONTEXT('USERENV','INSTANCE') instance,

  SYS_CONTEXT('USERENV','ENTRYID') entryid,

  SYS_CONTEXT('USERENV','ISDBA') isdba,

  SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,

  SYS_CONTEXT('USERENV','NLS_CURRENCY') nls_currency,

  SYS_CONTEXT('USERENV','NLS_CALENDAR') nls_calendar,

  SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,

  SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,

  SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,

  SYS_CONTEXT('USERENV','CURRENT_USER') current_user,

  SYS_CONTEXT('USERENV','CURRENT_USERID') current_userid,

  SYS_CONTEXT('USERENV','SESSION_USER') session_user,

  SYS_CONTEXT('USERENV','SESSION_USERID') session_userid,

  SYS_CONTEXT('USERENV','PROXY_USER') proxy_user,

  SYS_CONTEXT('USERENV','PROXY_USERID') proxy_userid,

  SYS_CONTEXT('USERENV','DB_DOMAIN') db_domain,

  SYS_CONTEXT('USERENV','DB_NAME') db_name,

  SYS_CONTEXT('USERENV','HOST') host,

  SYS_CONTEXT('USERENV','OS_USER') os_user,

  SYS_CONTEXT('USERENV','EXTERNAL_NAME') external_name,

  SYS_CONTEXT('USERENV','IP_ADDRESS') ip_address,

  SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') network_protocol,

  SYS_CONTEXT('USERENV','BG_JOB_ID') bg_job_id,

  SYS_CONTEXT('USERENV','FG_JOB_ID') fg_job_id,

  SYS_CONTEXT('USERENV','AUTHENTICATION_TYPE') authentication_type,

  SYS_CONTEXT('USERENV','AUTHENTICATION_DATA') authentication_data

  from dual ;

  其中,第二个参数的可选值如下:

  AUTHENTICATION_DATA

  Data being used to authenticate the login user. For X.503 certificate authenticated sessions, this field returns the context of the certificate in HEX2 format.

  Note: You can change the return value of the AUTHENTICATION_DATA attribute using the length parameter of the syntax. Values of up to 4000 are accepted. This is the only attribute of USERENV for which Oracle implements such a change.

  AUTHENTICATION_TYPE

  How the user was authenticated:

  DATABASE: username/password authentication

  OS: operating system external user authentication

  NETWORK: network protocol or ANO authentication

  PROXY: OCI proxy connection authentication