In Oracle mode, you can grant a role to a user by using SQL statements or in the OceanBase Cloud Platform (OCP) console.
Prerequisites
To grant 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 the administrator to obtain the privilege. For more information about how to grant privileges to a user, see Grant direct privileges. For more information about how to view your roles, see View roles.
Syntax and examples
The SQL syntax is as follows:
GRANT role_name TO grantee_user [WITH ADMID OPTION];
where:
role_namespecifies the name of the role. When you grant multiple roles to a user at a time, separate role names with commas (,).You can grant a role to multiple users at a time, or grant multiple roles to one or more users at a time.
WITH ADMIN OPTIONspecifies that the granted role can be granted to other users, and revoking the role does not automatically revoke the granted role from other users.
For example, grant 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.