REVOKE
Used for
Revoking privileges or role assignments
Available in
DSQL, ESQL
Syntax
The REVOKE
statement is used for revoking privileges from users, roles, stored procedures, triggers and views that were granted using the GRANT statement. See GRANT
for detailed descriptions of the various types of privileges.
Only the user who granted the privilege can revoke it.
The FROM
Clause
The FROM
clause is used to specify the list of users, roles and database objects (procedures, triggers and views) that will have the enumerated privileges revoked. The optional USER
and ROLE
keywords in the FROM
clause allow you to specify exactly which type is to have the privilege revoked. If a USER
or ROLE
keyword is not specified, the server checks for a role with this name and, if there is none, the privileges are revoked from the user without further checking.
Revoking the GRANT OPTION
The optional GRANT OPTION FOR
clause revokes the user’s privilege to grant privileges on the table, view, trigger or stored procedure to other users or to roles. It does not revoke the privilege with which the grant option is associated.
Removing the Privilege to One or More Roles
One usage of the REVOKE
statement is to remove roles that were assigned to a user, or a group of users, by a statement. In the case of multiple roles and/or multiple grantees, the REVOKE
verb is followed by the list of roles that will be removed from the list of users specified after the FROM
clause.
The optional ADMIN OPTION FOR
clause provides the means to revoke the grantee’s “administrator” privilege, the ability to assign the same role to other users, without revoking the grantee’s privilege to the role.
Multiple roles and grantees can be processed in a single statement.
Revoking Privileges That Were GRANTED BY
A privilege that has been granted using the GRANTED BY
clause is internally attributed explicitly to the grantor designated by that original GRANT
statement. To revoke a privilege that was obtained by this method, the current user must be logged in either with full administrative privileges or as the user designated as grantor by that GRANTED BY
clause.
Revoking ALL ON ALL
If the current user is logged in with full administrator privileges in the database, the statement
REVOKE ALL ON ALL FROM <grantee_list>
can be used to revoke all privileges (including role memberships) on all objects from one or more users and/or roles. All privileges for the user will be removed, regardless of who granted them. It is a quick way to “clear” privileges when access to the database must be blocked for a particular user or role.
If the current user is not logged in as an administrator, the only privileges revoked will be those that were granted originally by that user.
The REVOKE ALL ON ALL
statement cannot be used to revoke privileges that have been granted to stored procedures, triggers or views.
Examples using REVOKE
Revoking the privilege for reading the
CUSTOMER
table from theMANAGER
andENGINEER
roles and from the userIVAN
:REVOKE SELECT ON TABLE CUSTOMER
FROM ROLE MANAGER, ROLE ENGINEER, USER IVAN;
Revoking from the
ADMINISTRATOR
role the authority to grant any privileges on theCUSTOMER
table to other users or roles:Revoking the privilege for reading the
COUNTRY
table and the authority to reference theNAME
column of theCOUNTRY
table from any user, via the special user :REVOKE SELECT, REFERENCES (NAME) ON TABLE COUNTRY
FROM PUBLIC;
Revoking the privilege for reading the
EMPLOYEE
table from the userIVAN
, that was granted by the userALEX
:REVOKE SELECT ON TABLE EMPLOYEE
FROM USER IVAN GRANTED BY ALEX;
Revoking the privilege for inserting records into the
EMPLOYEE_PROJECT
table from theADD_EMP_PROJ
procedure:Revoking the privilege for executing the procedure
ADD_EMP_PROJ
from theMANAGER
role:REVOKE EXECUTE ON PROCEDURE ADD_EMP_PROJ
FROM ROLE MANAGER;
Revoking the
DIRECTOR
andMANAGER
roles from the userIVAN
:REVOKE DIRECTOR, MANAGER FROM USER IVAN;
Revoke from the user
ALEX
the authority to assign theMANAGER
role to other users:REVOKE ADMIN OPTION FOR MANAGER FROM USER IVAN;
Revoking all privileges (including roles) on all objects from the user
IVAN
:After this statement is executed, the user will have no privileges whatsoever.