After you create a role, you can grant the role to another role.
You can grant a role to any role other than itself. Circular role grant is not supported.
Prerequisites
To grant a role to another role, you must have the role to be granted, 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_name1 TO role_name2 [WITH ADMID OPTION];
where:
role_name1specifies the name of the role to be granted to another role. When you grant multiple roles to a role at a time, separate role names with commas (,).You can grant a role to multiple roles at a time, or grant multiple roles to one or more roles at a time.
WITH ADMIN OPTIONspecifies that the granted role can be granted to other users, and and revoking the role does not automatically revoke the granted role from other roles.
For example, grant the role2 role to the role1 role:
obclient> GRANT role2 TO role1;
Query OK, 0 rows affected
For more information about the GRANT statement, see GRANT.