Purpose
You can use this statement to set the default roles activated for users upon login.
Limitations and considerations
The user has the roles to be activated.
Required privileges
Notice
If a role is already granted to a user, you can specify to activate the role by default when you log in as the user without further authorization.
You must have the CREATE USER privilege. For more information about privileges in OceanBase Database, see Privilege types in MySQL mode.
Syntax
SET DEFAULT ROLE
{NONE | ALL | role_name [, role_name ...]}
TO user_name [, user_name ...];
Parameters
| Parameter | Description |
|---|---|
| NONE | Specifies to deactivate all roles granted to a user. |
| ALL | Specifies to activate all roles granted to a user. |
| role_name | The name of the role to be activated. Separate multiple roles with commas (,). |
| user_name | The username. To activate roles for multiple users, separate them with commas (,). |
Examples
Specify to activate the role001 and role002 roles granted to the user001 user by default when the user logs in.
obclient [test]> SET DEFAULT ROLE role001, role002 TO user001;