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, the current user must either hold the role being granted and have ADMIN OPTION on that role, or have the 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 ADMIN 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 OPTIONmeans the grantee may pass the role on to other users, and revoking the role from the grantee does not cascade to revoke it from those 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.
