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 direct privileges.
Examples
Grant the
role1role theALTER SYSTEMprivilege.obclient [oceanbase]> GRANT ALTER SYSTEM ON *.* TO role1;Grant the
role1role theSELECTprivilege on all objects in thedbtestdatabase.obclient [oceanbase]> GRANT SELECT ON dbtest.* TO role1;Grant multiple privileges to multiple roles at a time.
obclient [oceanbase]> GRANT SELECT,UPDATE ON dbtest.* TO role1,role2;Grant the
role1role theSELECTprivilege on thetest1.tbl1table.obclient [oceanbase]> GRANT SELECT ON test1.tbl1 TO role1;Grant the
role1role theSELECTprivilege on thec1column of thetest1.tbl1table.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 mode, see Privilege types in MySQL mode.