SET SESSION AUTHORIZATION
Function
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 statement only when the authenticated user name is specified.
Syntax
- Set the session user identifier and the current user identifier of the current session. - SET [ SESSION | LOCAL ] SESSION AUTHORIZATION role_name PASSWORD 'password';
- Reset the identifiers of the session and current users to the initially authenticated user names. - {SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT | RESET SESSION AUTHORIZATION};
Parameter Description
- SESSION - Specifies that the specified parameters take effect for the current session. 
- LOCAL - Specifies that the specified statement takes effect only for the current transaction. 
- role_name - Username - Value range: a string. It must comply with the identifier naming convention. 
- password - Specifies the password of a role. It must comply with the password convention. 
- DEFAULT - Resets the identifiers of the session and current users to the initially authenticated user names. 
Examples
-- Create a role paul.
openGauss=# CREATE ROLE paul IDENTIFIED BY 'xxxxxxxxx';
-- Set the current user to paul.
openGauss=# SET SESSION AUTHORIZATION paul password 'xxxxxxxxx';
-- View the current session user and the current user.
openGauss=# SELECT SESSION_USER, CURRENT_USER;
-- Reset the current user.
openGauss=# RESET SESSION AUTHORIZATION;
-- Delete the user.
openGauss=# DROP USER paul;