CURRENT_USER

CURRENT_USER is a system function in SQL that returns the name of the current user executing the transaction in the context of the current database session. The returned name refers to the user authenticated by SQL Server during the process of connection establishment.

CURRENT_USER()

Example

SELECT CURRENT_USER();

Output

'exampleUser@localhost'

Explanation

The CURRENT_USER() function is returning the user name and host name in the format ‘user@hostname’. In this example, the current user is ‘exampleUser’ and the host name is ‘localhost’.

CURRENT_USER()

Example

SELECT CURRENT_USER;

Output

'MyUser'

Explanation

The CURRENT_USER function returns the name of the current user in the SQL Server session. In this case, the returned username is ‘MyUser’.

CURRENT_USER

Example

SELECT CURRENT_USER FROM dual;

Output

'SCOTT'

Explanation

The CURRENT_USER function in Oracle returns the name of the user who executed the current SQL statement. In this example, the user “SCOTT” executed the SQL statement.

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