USERENV
USERENV(option)

Returns information about the current user.

Parameter

option

Specifies the exact piece of information to be returned, and must be one of the values listed in Table 5-7. The value returned by this function is always a VARCHAR2 character string.

Beginning with the Oracle 8.1.6 release, the SYS_CONTEXT function may also be used to retrieve these user environment values.

Table 5-7. USERENV Option Values
Option Description
ENTRYID Returns an auditing entry identifier. The AUDIT_TRAIL initialization parameter must be TRUE for this option to be valid, and you cannot use this option in a distributed environment.
INSTANCE Returns the instance identifier.
ISDBA Returns TRUE or FALSE, depending on whether or not the ISDBA role is enabled.
LANG Returns the abbreviation for the current ISO language.
LANGUAGE Returns the user's current language and territory settings.
SESSIONID Returns the auditing session identifier. The AUDIT_TRAIL initialization parameter must be TRUE for this option to be valid, and you cannot use this option in a distributed environment.
TERMINAL Returns the current session's operating system terminal identifier.

Example

SQL> SELECT USERENV('INSTANCE'),USERENV('ISDBA') FROM dual;

USERENV('INSTANCE') USEREN
------------------- ------
                  1 FALSE

Get Oracle SQL: the Essential Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.