After a role is created, you can grant it to any other user or role. You cannot grant a role to itself, and 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 the usertest1, and allow the user to further grant this 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 further granted to other roles or users.Grant the
employeerole to both usertest1and usertest2.obclient [oceanbase]> GRANT employee TO test1,test2;Grant both the
employeeanddeveloperroles to usertest1.obclient [oceanbase]> GRANT employee,developer TO test1;
Grant a role to a role
Grant the
employeerole to the rolerole1, 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 further granted to other roles or users.Grant the
employeerole to both rolesrole1androle2.obclient [oceanbase]> GRANT employee TO role1,role2;Grant both the
employeeanddeveloperroles to rolerole1.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.