查找userenv函数的时候,找到了sys_context函数,能够查找的内容比userenv更多,只是在工作中还未应用过,以后有机会尝试一下。
[@more@]In Oracle/PLSQL, the userenv function can be used to retrieve information about the current Oracle session. Although this function still exists in Oracle for backwards compatibility, it is recommended that you use the sys_context function instead.
The syntax for the userenv function is:
userenv( parameter )
parameter is the value to return from the current Oracle session. The possible values are:
Parameter Explanation CLIENT_INFO Returns user session information stored using the DBMS_APPLICATION_INFO package ENTRYID Available auditing entry identifier INSTANCE The identifier number of the current instance ISDBA Returns TRUE if the user has DBA privileges. Otherwise, it will return FALSE. LANG The ISO abbreviation for the language LANGUAGE The language, territory, and character of the session. In the following format:
language_territory.charactersetSESSIONID The identifier of the auditing session TERMINAL The OS identifier of the current session
For example:
userenv('ENTRYID') would return FALSE
userenv('LANGUAGE') would return 'AMERICAN_AMERICA.WE8DEC'
----------------------------------------------------------------------------------------------------------------------------------------------------
In Oracle/PLSQL, the sys_context function can be used to retrieve information about the Oracle environment.
The syntax for the sys_context function is:
sys_context( namespace, parameter, [ length ] )
namespace is an Oracle namespace that has already been created. If the namespace of 'USERENV' is used, attributes describing the current Oracle session can be returned.
parameter is a valid attribute that has been set using the DBMS_SESSION.set_context procedure.
length is optional. It is the length of the return value in bytes. If this parameter is omitted or if an invalid entry is provided, the sys_context function will default to 256 bytes.
The valid parameters for the namespace called 'USERENV' are as follows:
Parameter Explanation Return Length AUDITED_CURSORID Returns the cursor ID of the SQL that triggered the audit N/A AUTHENTICATION_DATA Authentication data 256 AUTHENTICATION_TYPE Describes how the user was authenticated. Can be one of the following values: Database, OS, Network, or Proxy 30 BG_JOB_ID If the session was established by an Oracle background process, this parameter will return the Job ID. Otherwise, it will return NULL. 30 CLIENT_IDENTIFIER Returns the client identifier (global context) 64 CLIENT_INFO User session information 64 CURRENT_SCHEMA Returns the default schema used in the current schema 30 CURRENT_SCHEMAID Returns the identifier of the default schema used in the current schema 30 CURRENT_SQL Returns the SQL that triggered the audit event 64 CURRENT_USER Name of the current user 30 CURRENT_USERID Userid of the current user 30 DB_DOMAIN Domain of the database from the DB_DOMAIN initialization parameter 256 DB_NAME Name of the database from the DB_NAME initialization parameter 30 ENTRYID Available auditing entry identifier 30 EXTERNAL_NAME External of the database user 256 FG_JOB_ID If the session was established by a client foreground process, this parameter will return the Job ID. Otherwise, it will return NULL. 30 GLOBAL_CONTEXT_MEMORY The number used in the System Global Area by the globally accessed context N/A HOST Name of the host machine from which the client has connected 54 INSTANCE The identifier number of the current instance 30 IP_ADDRESS IP address of the machine from which the client has connected 30 ISDBA Returns TRUE if the user has DBA privileges. Otherwise, it will return FALSE. 30 LANG The ISO abbreviate for the language 62 LANGUAGE The language, territory, and character of the session. In the following format:
language_territory.characterset52 NETWORK_PROTOCOL Network protocol used 256 NLS_CALENDAR The calendar of the current session 62 NLS_CURRENCY The currency of the current session 62 NLS_DATE_FORMAT The date format for the current session 62 NLS_DATE_LANGUAGE The language used for dates 62 NLS_SORT BINARY or the linguistic sort basis 62 NLS_TERRITORY The territory of the current session 62 OS_USER The OS username for the user logged in 30 PROXY_USER The name of the user who opened the current session on behalf of SESSION_USER 30 PROXY_USERID The identifier of the user who opened the current session on behalf of SESSION_USER 30 SESSION_USER The database user name of the user logged in 30 SESSION_USERID The database identifier of the user logged in 30 SESSIONID The identifier of the auditing session 30 TERMINAL The OS identifier of the current session 10
For example:
sys_context('USERENV', 'NLS_DATE_FORMAT') would return 'RR-MM-DD' sys_context('USERENV', 'NLS_SORT') would return 'BINARY'
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/76425/viewspace-912824/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/76425/viewspace-912824/