Oracle中USERENV和SYS_CONTEXT總結

ForTechnology發表於2011-08-17
Oracle中USERENV和SYS_CONTEXT總結
時間:2009-11-03 19:12:25來源:網路 作者:未知 點選:0次
Oracle中USERENV和SYS_CONTEXT用來返回當前session的資訊,其中,userenv是為了保持向下相容的遺留函式,推薦使用sys_context函式呼叫userenv名稱空間來獲取相關資訊。
Oracle中USERENV和SYS_CONTEXT用來返回當前session的資訊,其中,userenv是為了保持向下相容的遺留函式,推薦使用sys_context函式呼叫userenv名稱空間來獲取相關資訊。
1、 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;
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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25897606/viewspace-705154/,如需轉載,請註明出處,否則將追究法律責任。

相關文章