SET ROLE
Sets the current role for the session. Learn how to enable none, or a specific role to change your current privileges dynamically.
Syntax
SET ROLE { role | NONE }Description
The SET ROLE statement switches the current role for the session, enabling its associated permissions. To have no current role, set NONE.
If a role that doesn't exist, or to which the user has not been assigned, is specified, an ERROR 1959 (OP000): Invalid role specification error occurs.
An automatic SET ROLE is implicitly performed when a user connects if that user has been assigned a default role. See SET DEFAULT ROLE.
Example
--Checking the current role status
SELECT CURRENT_ROLE;+--------------+
| CURRENT_ROLE |
+--------------+
| NULL |
+--------------+--Setting the staff role, and verifying the switch
SET ROLE staff;
SELECT CURRENT_ROLE;This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

