SET ROLE sets the current user identifier of the current session.
1 | SET [ SESSION | LOCAL ] ROLE role_name PASSWORD 'password'; |
1 | RESET ROLE; |
Specifies that the command takes effect only for the current session. This parameter is used by default.
Value range: A string. It must comply with the naming convention rule.
Indicates that the specified command takes effect only for the current transaction.
Specifies the role name.
Value range: A string. It must comply with the naming convention rule.
Specifies the password of a role. It must comply with the password convention.
Resets the current user identifier.
Create a role named manager:
1 | CREATE ROLE paul IDENTIFIED BY '{Password}'; |
Set the current user to paul:
1 | SET ROLE paul PASSWORD '{Password}'; |
View the current session user and the current user:
1 | SELECT SESSION_USER, CURRENT_USER; |
Reset the current user:
1 | RESET role; |