Purpose
You can use this statement to set the default roles activated for users upon logon.
Limitations and considerations
The target users must have the roles to be activated.
Required privileges
Notice
To activate a granted role for yourself, you do not need any privileges.
You must have the CREATE USER privilege to activate roles for other users. 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
Activate the role001 and role002 roles for the user001 user by default upon logon.
obclient [test]> SET DEFAULT ROLE role001, role002 TO user001;