Oracle 中的userenv()

lhrbest發表於2017-03-17

 

1.USEREVN()

返回當前使用者環境的資訊,opt可以是:
ENTRYID,SESSIONID,TERMINAL,ISDBA,LABLE,LANGUAGE,CLIENT_INFO,LANG,VSIZE


1)ISDBA 檢視當前使用者是否是DBA如果是則返回true

SQL> select userenv('isdba') from dual;

USEREN
------
FALSE


2)SESSION 返回會話標誌

SQL> select userenv('sessionid') from dual;

USERENV('SESSIONID')
--------------------
152


3)ENTRYID 返回會話人口標誌

SQL> select userenv('entryid') from dual;

USERENV('ENTRYID')
------------------
0


4)INSTANCE 返回當前INSTANCE的標誌

SQL> select userenv('instance') from dual;

USERENV('INSTANCE')
-------------------
1


5)LANGUAGE 返回當前環境變數

SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK


6)LANG 返回當前環境的語言的縮寫

SQL> select userenv('lang') from dual;

USERENV('LANG')
----------------------------------------------------
ZHS


7)TERMINAL 返回使用者的終端或機器的標誌

SQL> select userenv('terminal') from dual;

USERENV('TERMINA
----------------
GAO


8)VSIZE(X) 返回X的大小(位元組)數

SQL> select vsize(user),user from dual;

VSIZE(USER) USER
----------- ------------------------------
6 SYSTEM


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/26736162/viewspace-2135554/,如需轉載,請註明出處,否則將追究法律責任。

相關文章