Chinaunix首页 | 论坛 | 博客
  • 博客访问: 343159
  • 博文数量: 115
  • 博客积分: 1019
  • 博客等级: 准尉
  • 技术积分: 1104
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-22 15:02
个人简介

别想万里,要把一只脚放到另一脚的前边

文章分类

全部博文(115)

文章存档

2018年(1)

2015年(2)

2014年(31)

2013年(38)

2012年(43)

我的朋友

分类: LINUX

2014-07-15 16:12:50


USEREVN -- 官方文档 functions228.htm#i79862
Oracle建议用  sys_context 来代替 userenv

USERENV(SESSIONID)               SYS_CONTEXT('USERENV','SESSIONID');

USEREVN()


返回当前用户环境<也就是sqlplus 所在电脑的环境>的信息,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


4.ENTRYID 返回会话人口标志


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

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


5.INSTANCE 返回当前INSTANCE的标志
SQL> select userenv('instance') from dual;

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


6.LANGUAGE 返回当前环境变量
SQL> select userenv('language') from dual;

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

7.LANG 返回当前环境的语言的缩写
SQL> select userenv('lang') from dual;

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


8.TERMINAL 返回用户的终端或机器的标志
SQL> select userenv('terminal') from dual;

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


9.VSIZE(X) 返回X的大小(字节)数
SQL> select vsize(user),user from dual;

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

2.sys_context

点击(此处)折叠或打开

  1.  select
  2.   SYS_CONTEXT('USERENV','TERMINAL') terminal,
  3.   SYS_CONTEXT('USERENV','LANGUAGE') language,
  4.   SYS_CONTEXT('USERENV','SESSIONID') sessionid,
  5.   SYS_CONTEXT('USERENV','INSTANCE') instance,
  6.   SYS_CONTEXT('USERENV','ENTRYID') entryid,
  7.   SYS_CONTEXT('USERENV','ISDBA') isdba,
  8.   SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,
  9.   SYS_CONTEXT('USERENV','NLS_CURRENCY') nls_currency,
  10.   SYS_CONTEXT('USERENV','NLS_CALENDAR') nls_calendar,
  11.   SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,
  12.   SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,
  13.   SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,
  14.   SYS_CONTEXT('USERENV','CURRENT_USER') current_user,
  15.   SYS_CONTEXT('USERENV','CURRENT_USERID') current_userid,
  16.   SYS_CONTEXT('USERENV','SESSION_USER') session_user,
  17.   SYS_CONTEXT('USERENV','SESSION_USERID') session_userid,
  18.   SYS_CONTEXT('USERENV','PROXY_USER') proxy_user,
  19.   SYS_CONTEXT('USERENV','PROXY_USERID') proxy_userid,
  20.   SYS_CONTEXT('USERENV','DB_DOMAIN') db_domain,
  21.   SYS_CONTEXT('USERENV','DB_NAME') db_name,
  22.   SYS_CONTEXT('USERENV','HOST') host,
  23.   SYS_CONTEXT('USERENV','OS_USER') os_user,
  24.   SYS_CONTEXT('USERENV','EXTERNAL_NAME') external_name,
  25.   SYS_CONTEXT('USERENV','IP_ADDRESS') ip_address,
  26.   SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') network_protocol,
  27.   SYS_CONTEXT('USERENV','BG_JOB_ID') bg_job_id,
  28.   SYS_CONTEXT('USERENV','FG_JOB_ID') fg_job_id,
  29.   SYS_CONTEXT('USERENV','AUTHENTICATION_TYPE') authentication_type,
  30.   SYS_CONTEXT('USERENV','AUTHENTICATION_DATA') authentication_data
  31.   from dual



 
阅读(3907) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~