Purpose
This statement is used to set the default activated role for a user when they log in.
Limitations and considerations
The current user must have the specified role to execute this operation.
Privilege requirements
Notice
If the user is setting the default activated role for themselves, no privileges are required.
To activate a role, the current user must have the CREATE USER privilege. For more information about OceanBase Database privileges, see Privilege classification in MySQL mode.
Syntax
SET DEFAULT ROLE
{NONE | ALL | role_name [, role_name ...]}
TO user_name [, user_name ...];
Parameters
| Parameter | Description |
|---|---|
| NONE | Specifies to disable all roles granted to the user. |
| ALL | Specifies to activate all roles of the user. |
| role_name | Specifies the name of the role. Separate multiple role names with commas (,). |
| user_name | Specifies the name of the user. Separate multiple user names with commas (,). |
Examples
Specify that the default activated roles for user user001 when they log in are role001 and role002.
obclient [test]> SET DEFAULT ROLE role001, role002 TO user001;
