这个函数在写一些触发器,函数的时候非常有用处。 用法: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. Valuesof up to4000 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. Nullif the session was not established by a background process. CLIENT_INFO Returns up to64 bytes ofuser session information that can be stored by an application using the DBMS_APPLICATION_INFO package. CURRENT_SCHEMA Name of the defaultschema being used in the currentschema. This value can be changed during the session with an ALTER SESSION SET CURRENT_SCHEMA statement. CURRENT_SCHEMAID Identifier of the defaultschema 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 databaseas specified in the DB_DOMAIN initialization parameter. DB_NAME Name of the databaseas specified in the DB_NAME initialization parameter. ENTRYID The available auditing entry identifier. You cannot use this optionindistributed SQL statements. Touse this keyword in USERENV, the initialization parameter AUDIT_TRAIL must be setto true. EXTERNAL_NAME External name of the databaseuser. 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. Nullif 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 numberof the current instance. IP_ADDRESS IP address of the machine from which the client is connected. ISDBA TRUE if you are logged onas 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 databasecharacterset, 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 databaseuser who opened the current session on behalf ofSESSION_USER. PROXY_USERID Identifier of the databaseuser who opened the current session on behalf ofSESSION_USER. SESSION_USER Databaseuser name by which the currentuseris authenticated. This value remains the same throughout the duration of the session. SESSION_USERID Identifier of the databaseuser name by which the currentuseris authenticated. SESSIONID The auditing session identifier. You cannot use this optionindistributed SQL statements. TERMINAL The operating system identifier for the client of the current session. Indistributed SQL statements, this optionreturns the identifier for your local session. In a distributed environment, this is supported onlyfor remote SELECT statements, notfor remote INSERT, UPDATE, orDELETE operations. (The return length of this parameter may vary by operating system.)