Oracle中獲取會話信息的兩個函數(shù)分享
來源:易賢網(wǎng) 閱讀:891 次 日期:2015-03-17 11:36:28
溫馨提示:易賢網(wǎng)小編為您整理了“Oracle中獲取會話信息的兩個函數(shù)分享”,方便廣大網(wǎng)友查閱!

1、 USERENV(OPTION)

返回當(dāng)前的會話信息.

OPTION='ISDBA'若當(dāng)前是DBA角色,則為TRUE,否則FALSE.

OPTION='LANGUAGE'返回數(shù)據(jù)庫的字符集.

OPTION='SESSIONID'為當(dāng)前會話標(biāo)識符.

OPTION='ENTRYID'返回可審計的會話標(biāo)識符.

OPTION='LANG'返回會話語言名稱的ISO簡記.

OPTION='INSTANCE'返回當(dāng)前的實例.

OPTION='terminal'返回當(dāng)前計算機名

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

3.與系統(tǒng)視圖v$session組合使用可以獲得更多信息(客戶端所使用的應(yīng)用程序等)

代碼如下:

select *

from v$session se,

(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) base

where se.AUDSID = base.sessionid;

更多信息請查看IT技術(shù)專欄

更多信息請查看數(shù)據(jù)庫
易賢網(wǎng)手機網(wǎng)站地址:Oracle中獲取會話信息的兩個函數(shù)分享
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報警專用圖標(biāo)