SESSION_USER

SESSION_USER is a system function in SQL that returns the name of the user account under which the current database session is running. It takes no arguments and returns a string.

SESSION_USER()

Example

SELECT SESSION_USER;

Output

session_user
------------------
postgres
(1 row)

Explanation

The SESSION_USER is a system information function in PostgreSQL. It returns the name of the current user executing the query. In the given example, it returns ‘postgres’ as currently the query is executed through this user.

SESSION_USER()

Example

SELECT SESSION_USER as 'Session User';

Output

Session User
---------------------------------
your_user_name

Explanation

The SESSION_USER function returns the user name of the current SQL Server session. In this example, your_user_name is the name of the current user.

SESSION_USER

Example

SELECT SESSION_USER FROM DUAL;

Output

"SCOTT"

Explanation

In the given example, SESSION_USER is a function that returns the name of the currently authenticated user. The DUAL is a special one-row and one-column table present by default in all Oracle databases.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.