天天看點

Oracle 中的userenv()

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')

------------------

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;

繼續閱讀