Skip to content
July 2, 2010 / doganay

SYS_CONTEXT

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Hi,

We can use sys_context or userenv to get values like os_user, etc. in oracle.

You may use this:

SELECT SYS_CONTEXT (‘USERENV’, ‘OS_USER’) FROM DUAL;

or this:

SELECT USERENV(‘OS_USER’) FROM DUAL;

Anyway,  here are some handy sys_context sqls, try and pray 🙂

SELECT SYS_CONTEXT (‘USERENV’, ‘AUTHENTICATED_IDENTITY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘AUTHENTICATION_METHOD’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘AUTHENTICATION_TYPE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_SCHEMA’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_SCHEMAID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_USER’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_USERID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘DB_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘DB_UNIQUE_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘EXTERNAL_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘FG_JOB_ID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘GLOBAL_CONTEXT_MEMORY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘HOST’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘IDENTIFICATION_TYPE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘INSTANCE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘INSTANCE_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘IP_ADDRESS’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘ISDBA’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘LANG’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘LANGUAGE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘MODULE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NETWORK_PROTOCOL’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_CALENDAR’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_CURRENCY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_DATE_FORMAT’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_DATE_LANGUAGE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_SORT’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_TERRITORY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘OS_USER’) FROM DUAL;
SELECT USERENV(‘OS_USER’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SERVER_HOST’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SERVICE_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SESSION_USER’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SESSION_USERID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SESSIONID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SID’) FROM DUAL;—–>The session number (different from the session ID).
SELECT SYS_CONTEXT (‘USERENV’, ‘TERMINAL’) FROM DUAL;

SELECT SYS_CONTEXT (‘USERENV’, ‘AUTHENTICATED_IDENTITY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘AUTHENTICATION_METHOD’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘AUTHENTICATION_TYPE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_SCHEMA’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_SCHEMAID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_USER’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘CURRENT_USERID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘DB_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘DB_UNIQUE_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘EXTERNAL_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘FG_JOB_ID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘GLOBAL_CONTEXT_MEMORY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘HOST’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘IDENTIFICATION_TYPE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘INSTANCE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘INSTANCE_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘IP_ADDRESS’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘ISDBA’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘LANG’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘LANGUAGE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘MODULE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NETWORK_PROTOCOL’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_CALENDAR’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_CURRENCY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_DATE_FORMAT’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_DATE_LANGUAGE’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_SORT’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘NLS_TERRITORY’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘OS_USER’) FROM DUAL;SELECT USERENV(‘OS_USER’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SERVER_HOST’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SERVICE_NAME’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SESSION_USER’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SESSION_USERID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SESSIONID’) FROM DUAL;
SELECT SYS_CONTEXT (‘USERENV’, ‘SID’) FROM DUAL;—–>The session number (different from the session ID).
SELECT SYS_CONTEXT (‘USERENV’, ‘TERMINAL’) FROM DUAL;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: