Purpose
This statement is used to activate the roles granted to the current login user in the current session.
Note
The roles activated by the SET ROLE statement only take effect in the current session and do not affect subsequent sessions.
Syntax
SET ROLE {
DEFAULT
| NONE
| ALL
| ALL EXCEPT role_name [, role_name ...]
| role_name [, role_name ...]
};
Parameters
| Parameter | Description |
|---|---|
| DEFAULT | Specifies the setting to keep the default role. The system activates roles based on the value of the activate_all_roles_on_login variable and the default activated roles set by the SET DEFAULT ROLE or ALTER USER statement:
|
| NONE | Specifies to disable all roles granted to the user. |
| ALL | Specifies to activate all roles granted to the user. |
| ALL EXCEPT | Specifies to deactivate roles granted to the user. |
| role_name | Specifies the name of the role. When activating multiple roles, separate the role names with commas (,). |
Examples
Specify to activate all roles granted to the user in the current session, except for the
role001role.obclient [(none)]> SET ROLE ALL EXCEPT role001;Specify to activate the
role001androle002roles of the user in the current session.obclient [(none)]> SET ROLE role001, role002;
