You can assign a role to a user in Oracle mode by using SQL statements or OceanBase Cloud Platform (OCP).
Assign a role by using SQL statements
To assign a role to a user, you must have a role and the ADMIN OPTION or GRANT ANY ROLE privilege.
For information about how to view your privileges, see View user privileges. If you do not have the required privilege, contact an administrator. For more information, see Modify user privileges. For more information about how to view your roles, see View roles.
Execute the following SQL statement to assign a role to a user:
GRANT role_name TO grantee_user [WITH ADMID OPTION];
Notes:
role_name: the name of the role. When you assign multiple roles to a user at a time, separate role names with commas (,).You can assign a role to multiple users at a time, or assign multiple roles to one or more users at a time.
WITH ADMIN OPTION: specifies that the assigned role can be assigned to other users, and role revocation does not extend to other users.
Example: assign the role1 role to the user2 user.
obclient> GRANT role1 TO user2;
Query OK, 0 rows affected
For more information about the GRANT statement, see GRANT.