This topic describes how to grant a role to a user or another role. You cannot grant a role to itself. Circular role granting is not supported.
You can grant one or more roles to one or more users or roles.
Prerequisites
You have the roles to be granted and the ADMIN OPTION privilege. For more information about how to view your privileges, see View user privileges.
Examples
Grant a role to a user
Grant the
employeerole to thetest1user and allow the user to grant the role to other users or roles.obclient [oceanbase]> GRANT employee TO test1 WITH ADMIN OPTION;In this example, the
WITH ADMIN OPTIONclause specifies whether the role can be granted to other roles or users.Grant the
employeerole to thetest1andtest2users.obclient [oceanbase]> GRANT employee TO test1,test2;Grant the
employeeanddeveloperroles to thetest1user.obclient [oceanbase]> GRANT employee,developer TO test1;
Grant a role to another role
Grant the
employeerole to therole1role, and allow therole1role to grant theemployeerole to other roles or users.obclient [oceanbase]> GRANT employee TO role1 WITH ADMIN OPTION;In this example, the
WITH ADMIN OPTIONclause specifies whether the role can be granted to other roles or users.Grant the
employeerole to therole1androle2roles.obclient [oceanbase]> GRANT employee TO role1,role2;Grant the
employeeanddeveloperroles to therole1role.obclient [oceanbase]> GRANT employee,developer TO role1;
What to do next
To use the privileges of a granted role, the granted role must be activated. For information about how to activate a role, see Activate a role.
References
For more information about the GRANT statement, see GRANT.