天天看点

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;

继续阅读