Revoke a role from a user or role
You can use the REVOKE statement to revoke a role from a user or another role.
Currently, you can revoke one role from multiple users or roles, revoke multiple roles from one user or role, or revoke multiple roles from multiple users or roles.
Prerequisites
To revoke a role, the current user must have the role to be revoked and the ADMIN OPTION privilege. For more information about how to view the roles of the current user or role, see View roles.
Considerations
When you execute the REVOKE statement to revoke a role from a user, the change does not take effect immediately for the currently logged-in user.
Examples
Revoke a role from a user
-
Revoke the
employeerole from thetest1user.REVOKE employee FROM test1; -
Revoke the
employeerole from thetest1andtest2users.REVOKE employee FROM test1,test2 IGNORE UNKNOWN USER;In this example, the
IGNORE UNKNOWN USERclause is used to check whether the users to be revoked exist. If you do not specify theIGNORE UNKNOWN USERclause, an error is returned if either thetest1ortest2user does not exist. If you specify theIGNORE UNKNOWN USERclause, a warning is returned.Regardless of whether you specify the
IGNORE UNKNOWN USERclause, the operation fails if either thetest1ortest2user does not exist. -
Revoke the
employeeanddeveloperroles from thetest1user.REVOKE IF EXISTS employee,developer FROM test1 IGNORE UNKNOWN USER;In this example, the
IF EXISTSclause is used to check whether the roles to be revoked exist. If you do not specify theIF EXISTSclause, an error is returned if either theemployeeordeveloperrole does not exist. If you specify theIF NOT EXISTSclause, a warning is returned.Regardless of whether you specify the
IF EXISTSclause, the operation fails if either theemployeeordeveloperrole does not exist.
Revoke a role from a role
-
Revoke the
employeerole from therole1role.REVOKE employee FROM role1; -
Revoke the
employeerole from therole1androle2roles.REVOKE IF EXISTS employee FROM role1,role2;
References
-
For more information about the
REVOKEstatement, see REVOKE.