This topic describes how to revoke a role from a user or another role by using the REVOKE statement.
You can revoke one or more roles from one or more users or roles.
Prerequisites
You have the roles to be revoked and the ADMIN OPTION privilege. For information about how to view the roles of a user or role, see View roles.
Notice
The REVOKE statement does not take immediate effect on the current user.
Examples
Revoke a role from a user
Revoke the
employeerole from thetest1user.obclient [oceanbase]> REVOKE employee FROM test1;Revoke the
employeerole from thetest1andtest2users.obclient [oceanbase]> REVOKE employee FROM test1,test2 IGNORE UNKNOWN USER;In this example, the
IGNORE UNKNOWN USERclause is used to check whether the specified users exist. Assuming that thetest1ortest2user does not exist, an error is reported if you do not use the clause, or a warning message is returned if you use the clause.If the
test1ortest2user does not exist, the revoke operation fails regardless of whether you use theIGNORE UNKNOWN USERclause.Revoke the
employeeanddeveloperroles from thetest1user.obclient [oceanbase]> REVOKE IF EXISTS employee,developer FROM test1 IGNORE UNKNOWN USER;In this example, the
IF EXISTSclause is used to check whether the specified roles exist in the tenant. Assuming that theemployeeordeveloperrole does not exist, an error is reported if you do not use the clause, or a warning message is returned if you use the clause.If the
employeeordeveloperrole does not exist, the revoke operation fails regardless of whether you use theIF EXISTSclause.
Revoke a role from another role
Revoke the
employeerole from therole1role.obclient [oceanbase]> REVOKE employee FROM role1;Revoke the
employeerole from therole1androle2roles.obclient [oceanbase]> REVOKE IF EXISTS employee FROM role1,role2;
References
For more information about the
REVOKEstatement, see REVOKE.