Updated on 2025-07-22 GMT+08:00

SET SESSION AUTHORIZATION

Function

SET SESSION AUTHORIZATION sets the session user identifier and the current user identifier of the current SQL session to a specified user.

Precautions

The session identifier can be changed only when the initial session user has the system administrator rights. Otherwise, the system supports the command only when the authenticated user name is specified.

Syntax

  • SET SESSION AUTHORIZATION sets the session user identifier and the current user identifier of the current session.
    1
    SET [ SESSION | LOCAL ] SESSION AUTHORIZATION role_name PASSWORD '{password}';
    
  • Reset the identifiers of the session and current users to the initially authenticated user names.
    1
    2
    {SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
        | RESET SESSION AUTHORIZATION};
    

Parameter Description

Table 1 SET SESSION AUTHORIZATION parameters

Parameter

Description

Value Range

SESSION

Indicates that the specified parameters take effect for the current session.

A string, which must comply with the naming convention.

LOCALE

Indicates that the specified command takes effect only for the current transaction.

-

role_name

User name.

A string, which must comply with the naming convention.

password

Specifies the password of a role. It must comply with the password convention.

-

DEFAULT

Reset the identifiers of the session and current users to the initially authenticated user names.

-

Examples

Set the current user to paul:

1
SET SESSION AUTHORIZATION paul password '{password}';

View the current session user and the current user:

1
SELECT SESSION_USER, CURRENT_USER;

Reset the current user:

1
RESET SESSION AUTHORIZATION;

Helpful Links

SET ROLE