This topic describes how to grant privileges to a role after the role is created, so that users granted the role can use the privileges of the role.
Prerequisites
You have the privileges to be granted and the GRANT OPTION privilege. For more 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 privileges directly.
Examples
Grant the
ALTER SYSTEMprivilege to the rolerole1.obclient [oceanbase]> GRANT ALTER SYSTEM ON *.* TO role1;Grant the
SELECTprivilege on all objects in the databasedbtestto the rolerole1.obclient [oceanbase]> GRANT SELECT ON dbtest.* TO role1;You can add one or more privileges to multiple roles at the same time.
obclient [oceanbase]> GRANT SELECT,UPDATE ON dbtest.* TO role1,role2;Grant the
SELECTprivilege on the tabletest1.tbl1to the rolerole1.obclient [oceanbase]> GRANT SELECT ON test1.tbl1 TO role1;Grant the
SELECTprivilege on columnc1of the tabletest1.tbl1to the rolerole1.obclient [oceanbase]> GRANT SELECT(c1) ON test1.tbl1 TO role1;
References
For more information about the
GRANTstatement, see GRANT.For more information about the privileges supported in MySQL-compatible mode, see Permission classification.