Oracle Database - Userenv (Current Session Informations)

About

Userenv is a pre-build context that describes the current session.

How to

Query it

You can query the context Userenv with two functions.

SELECT SYS_CONTEXT('USERENV','SESSIONID') FROM DUAL;
  • or the USERENV function <note warning>Deprectaed</note>
SELECT USERENV('SESSIONID') FROM DUAL;

Get the Parameters

You can see all the SYS_CONTEXT parameters in the SQL documentation. Predefined Parameters of Namespace USERENV

CURRENT_SCHEMA

current_user

LANGUAGE

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.WE8ISO8859P1

It gives the session's <language>_<territory> but the DATABASE character set, so the value returned is not the client's NLS_LANG setting!


Powered by ComboStrap