返回列表 回复 发帖

关于userenv

请问那里有关于userenv的资料。
或者谁介绍下。谢谢!
返回当前用户环境的信息,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
高义明
msn:gaoyiminggoerp@hotmail.com
专注Oracle HRMS----Core HR\Payroll...........
事业中,就是要发展好ERP100,更好的服务大家
------------------------------------------------------------------------------------------
我们一起共建Erp100,你肯定有信心!
USERENVSyntaxuserenv::=


Purpose

Note: USERENV is a legacy function that is retained for backward compatibility. Oracle Corporation recommends that you use the SYS_CONTEXT function with the built-in USERENV namespace for current functionality.

USERENV returns information about the current session. This information can be useful for writing an application-specific audit trail table or for determining the language-specific characters currently used by your session. You cannot use USERENV in the condition of a CHECK constraint.
All calls to USERENV return VARCHAR2 data except for calls with the SESSIONID, ENTRYID, and COMMITSCN parameters, which return NUMBER.
Table 6-3  Parameters of the USERENV Function
ParameterReturn Value
CLIENT_INFO
CLIENT_INFO returns up to 64 bytes of user session information that can be stored by an application using the DBMS_APPLICATION_INFO package.
Caution: Some commercial applications may be using this context value. Check the applicable documentation for those applications to determine what restrictions they may impose on use of this context area.

ENTRYID
ENTRYID returns available auditing entry identifier. You cannot use this attribute in distributed SQL statements. To use this keyword in USERENV, the initialization parameter AUDIT_TRAIL must be set to TRUE.
ISDBA
ISDBA returns 'TRUE' if the user has been authenticated as having DBA privileges either through the operating system or through a password file.
LANG
LANG returns the ISO abbreviation for the language name, a shorter form than the existing 'LANGUAGE' parameter.
LANGUAGE
LANGUAGE returns the language and territory currently used by your session along with the database character set in this form:
language_territory.characterset
SESSIONID
SESSIONID returns your auditing session identifier. You cannot use this attribute in distributed SQL statements.
TERMINAL
TERMINAL returns the operating system identifier for your current session's terminal. In distributed SQL statements, this attribute returns the identifier for your local session. In a distributed environment, this is supported only for remote SELECT statements, not for remote INSERT, UPDATE, or DELETE operations.
ExamplesThe following example returns the LANGUAGE parameter of the current session:
SELECT USERENV('LANGUAGE') "Language" FROM DUAL;Language-----------------------------------AMERICAN_AMERICA.WE8DEC
高义明
msn:gaoyiminggoerp@hotmail.com
专注Oracle HRMS----Core HR\Payroll...........
事业中,就是要发展好ERP100,更好的服务大家
------------------------------------------------------------------------------------------
我们一起共建Erp100,你肯定有信心!
谢谢!
SELECT sys_context('USERENV', 'OS_USER') FROM dual;

SELECT sys_context('USERENV', 'DB_NAME') FROM dual;
用法:SELECT sys_context('USERENV', '<parameter>') FROM dual;

第二个参数的可选值:
AUTHENTICATION_DATA
Data being used to authenticate the login user. For X.503 certificate authenticated sessions, this field returns the context of the certificate in HEX2 format.
Note: You can change the return value of the AUTHENTICATION_DATA attribute using the length parameter of the syntax. Values of up to 4000 are accepted. This is the only attribute of USERENV for which Oracle implements such a change.

AUTHENTICATION_TYPE
How the user was authenticated:
DATABASE: username/password authentication
OS: operating system external user authentication
NETWORK: network protocol or ANO authentication
PROXY: OCI proxy connection authentication

BG_JOB_ID
Job ID of the current session if it was established by an Oracle background process. Null if the session was not established by a background process.

CLIENT_INFO
Returns up to 64 bytes of user session information that can be stored by an application using the DBMS_APPLICATION_INFO package.

CURRENT_SCHEMA
Name of the default schema being used in the current schema. This value can be changed during the session with an ALTER SESSION SET CURRENT_SCHEMA statement.

CURRENT_SCHEMAID
Identifier of the default schema being used in the current session.

CURRENT_USER
The name of the user whose privilege the current session is under.

CURRENT_USERID
User ID of the user whose privilege the current session is under.

DB_DOMAIN
Domain of the database as specified in the DB_DOMAIN initialization parameter.

DB_NAME
Name of the database as specified in the DB_NAME initialization parameter.

ENTRYID
The available auditing entry identifier. You cannot use this option in distributed SQL statements. To use this keyword in USERENV, the initialization parameter AUDIT_TRAIL must be set to true.

EXTERNAL_NAME
External name of the database user. For SSL authenticated sessions using v.503 certificates, this field returns the distinguished name (DN) stored in the user certificate.

FG_JOB_ID
Job ID of the current session if it was established by a client foreground process. Null if the session was not established by a foreground process.

HOST
Name of the host machine from which the client has connected.

INSTANCE
The instance identification number of the current instance.

IP_ADDRESS
IP address of the machine from which the client is connected.

ISDBA
TRUE if you are logged on as SYS.

LANG
The ISO abbreviation for the language name, a shorter form than the existing 'LANGUAGE' parameter.

LANGUAGE
The language and territory currently used by your session, along with the database character set, in the form:language_territory.characterset.

NETWORK_PROTOCOL
Network protocol being used for communication, as specified in the 'PROTOCOL=protocol' portion of the connect string.

NLS_CALENDAR
The current calendar of the current session.

NLS_CURRENCY
The currency of the current session.

NLS_DATE_FORMAT
The date format for the session.

NLS_DATE_LANGUAGE
The language used for expressing dates.

NLS_SORT BINARY
or the linguistic sort basis.

NLS_TERRITORY
The territory of the current session.

OS_USER
Operating system username of the client process that initiated the database session.

PROXY_USER
Name of the database user who opened the current session on behalf of SESSION_USER.

PROXY_USERID
Identifier of the database user who opened the current session on behalf of SESSION_USER.

SESSION_USER
Database user name by which the current user is authenticated. This value remains the same throughout the duration of the session.

SESSION_USERID
Identifier of the database user name by which the current user is authenticated.

SESSIONID
The auditing session identifier. You cannot use this option in distributed SQL statements.

TERMINAL
The operating system identifier for the client of the current session. In distributed SQL statements, this option returns the identifier for your local session. In a distributed environment, this is supported only for remote SELECT statements, not for remote INSERT, UPDATE, or DELETE operations.
(The return length of this parameter may vary by operating system
http://renzhek.erp100.com
email: renzhek@hotmail.com
总结的不错,学习
这个很有用啊。哈哈。记下了。可否转载啊?
有事找我
Email xiaobin5595@sina.com
我也在学EBS研究一下啊!
MSN buyapeng@hotmail.com
thanks
返回列表