Removes access privileges.

Synopsis

  1. REVOKE [GRANT OPTION FOR] { {SELECT | INSERT | UPDATE | DELETE
  2. | REFERENCES | TRIGGER | TRUNCATE } [, ...] | ALL [PRIVILEGES] }
  3. ON { [TABLE] <table_name> [, ...]
  4. | ALL TABLES IN SCHEMA schema_name [, ...] }
  5. FROM { [ GROUP ] <role_name> | PUBLIC} [, ...]
  6. [CASCADE | RESTRICT]
  7. REVOKE [ GRANT OPTION FOR ] { { SELECT | INSERT | UPDATE
  8. | REFERENCES } ( <column_name> [, ...] )
  9. [, ...] | ALL [ PRIVILEGES ] ( <column_name> [, ...] ) }
  10. ON [ TABLE ] <table_name> [, ...]
  11. FROM { [ GROUP ] <role_name> | PUBLIC } [, ...]
  12. [ CASCADE | RESTRICT ]
  13. REVOKE [GRANT OPTION FOR] { {USAGE | SELECT | UPDATE} [,...]
  14. | ALL [PRIVILEGES] }
  15. ON { SEQUENCE <sequence_name> [, ...]
  16. | ALL SEQUENCES IN SCHEMA schema_name [, ...] }
  17. FROM { [ GROUP ] <role_name> | PUBLIC } [, ...]
  18. [CASCADE | RESTRICT]
  19. REVOKE [GRANT OPTION FOR] { {CREATE | CONNECT
  20. | TEMPORARY | TEMP} [, ...] | ALL [PRIVILEGES] }
  21. ON DATABASE <database_name> [, ...]
  22. FROM { [ GROUP ] <role_name> | PUBLIC} [, ...]
  23. [CASCADE | RESTRICT]
  24. REVOKE [ GRANT OPTION FOR ]
  25. { USAGE | ALL [ PRIVILEGES ] }
  26. ON DOMAIN <domain_name> [, ...]
  27. FROM { [ GROUP ] <role_name> | PUBLIC } [, ...]
  28. [ CASCADE | RESTRICT ]
  29. REVOKE [ GRANT OPTION FOR ]
  30. { USAGE | ALL [ PRIVILEGES ] }
  31. ON FOREIGN DATA WRAPPER <fdw_name> [, ...]
  32. FROM { [ GROUP ] <role_name> | PUBLIC } [, ...]
  33. [ CASCADE | RESTRICT ]
  34. REVOKE [ GRANT OPTION FOR ]
  35. { USAGE | ALL [ PRIVILEGES ] }
  36. ON FOREIGN SERVER <server_name> [, ...]
  37. FROM { [ GROUP ] <role_name> | PUBLIC } [, ...]
  38. [ CASCADE | RESTRICT ]
  39. REVOKE [GRANT OPTION FOR] {EXECUTE | ALL [PRIVILEGES]}
  40. ON { FUNCTION <funcname> ( [[<argmode>] [<argname>] <argtype>
  41. [, ...]] ) [, ...]
  42. | ALL FUNCTIONS IN SCHEMA schema_name [, ...] }
  43. FROM { [ GROUP ] <role_name> | PUBLIC} [, ...]
  44. [CASCADE | RESTRICT]
  45. REVOKE [GRANT OPTION FOR] {USAGE | ALL [PRIVILEGES]}
  46. ON LANGUAGE <langname> [, ...]
  47. FROM { [ GROUP ] <role_name> | PUBLIC} [, ...]
  48. [ CASCADE | RESTRICT ]
  49. REVOKE [GRANT OPTION FOR] { {CREATE | USAGE} [, ...]
  50. | ALL [PRIVILEGES] }
  51. ON SCHEMA <schema_name> [, ...]
  52. FROM { [ GROUP ] <role_name> | PUBLIC} [, ...]
  53. [CASCADE | RESTRICT]
  54. REVOKE [GRANT OPTION FOR] { CREATE | ALL [PRIVILEGES] }
  55. ON TABLESPACE <tablespacename> [, ...]
  56. FROM { [ GROUP ] <role_name> | PUBLIC } [, ...]
  57. [CASCADE | RESTRICT]
  58. REVOKE [ GRANT OPTION FOR ]
  59. { USAGE | ALL [ PRIVILEGES ] }
  60. ON TYPE <type_name> [, ...]
  61. FROM { [ GROUP ] <role_name> | PUBLIC } [, ...]
  62. [ CASCADE | RESTRICT ]
  63. REVOKE [ADMIN OPTION FOR] <parent_role> [, ...]
  64. FROM [ GROUP ] <member_role> [, ...]
  65. [CASCADE | RESTRICT]

Description

REVOKE command revokes previously granted privileges from one or more roles. The key word PUBLIC refers to the implicitly defined group of all roles.

See the description of the GRANT command for the meaning of the privilege types.

Note that any particular role will have the sum of privileges granted directly to it, privileges granted to any role it is presently a member of, and privileges granted to PUBLIC. Thus, for example, revoking SELECT privilege from PUBLIC does not necessarily mean that all roles have lost SELECT privilege on the object: those who have it granted directly or via another role will still have it. Similarly, revoking SELECT from a user might not prevent that user from using SELECT if PUBLIC or another membership role still has SELECT rights.

If GRANT OPTION FOR is specified, only the grant option for the privilege is revoked, not the privilege itself. Otherwise, both the privilege and the grant option are revoked.

If a role holds a privilege with grant option and has granted it to other roles then the privileges held by those other roles are called dependent privileges. If the privilege or the grant option held by the first role is being revoked and dependent privileges exist, those dependent privileges are also revoked if CASCADE is specified, else the revoke action will fail. This recursive revocation only affects privileges that were granted through a chain of roles that is traceable to the role that is the subject of this REVOKE command. Thus, the affected roles may effectively keep the privilege if it was also granted through other roles.

When you revoke privileges on a table, Greenplum Database revokes the corresponding column privileges (if any) on each column of the table, as well. On the other hand, if a role has been granted privileges on a table, then revoking the same privileges from individual columns will have no effect.

When revoking membership in a role, GRANT OPTION is instead called ADMIN OPTION, but the behavior is similar.

Parameters

See GRANT.

Notes

A user may revoke only those privileges directly granted by that user. If, for example, user A grants a privilege with grant option to user B, and user B has in turn granted it to user C, then user A cannot revoke the privilege directly from C. Instead, user A could revoke the grant option from user B and use the CASCADE option so that the privilege is in turn revoked from user C. For another example, if both A and B grant the same privilege to C, A can revoke their own grant but not B’s grant, so C effectively still has the privilege.

When a non-owner of an object attempts to REVOKE privileges on the object, the command fails outright if the user has no privileges whatsoever on the object. As long as some privilege is available, the command proceeds, but it will revoke only those privileges for which the user has grant options. The REVOKE ALL PRIVILEGES forms issue a warning message if no grant options are held, while the other forms issue a warning if grant options for any of the privileges specifically named in the command are not held. (In principle these statements apply to the object owner as well, but since Greenplum Database always treats the owner as holding all grant options, the cases can never occur.)

If a superuser chooses to issue a GRANT or REVOKE command, Greenplum Database performs the command as though it were issued by the owner of the affected object. Since all privileges ultimately come from the object owner (possibly indirectly via chains of grant options), it is possible for a superuser to revoke all privileges, but this might require use of CASCADE as stated above.

REVOKE may also be invoked by a role that is not the owner of the affected object, but is a member of the role that owns the object, or is a member of a role that holds privileges WITH GRANT OPTION on the object. In this case, Greenplum Database performs the command as though it were issued by the containing role that actually owns the object or holds the privileges WITH GRANT OPTION. For example, if table t1 is owned by role g1, of which role u1 is a member, then u1 can revoke privileges on t1 that are recorded as being granted by g1. This includes grants made by u1 as well as by other members of role g1.

If the role that runs REVOKE holds privileges indirectly via more than one role membership path, it is unspecified which containing role will be used to perform the command. In such cases it is best practice to use SET ROLE to become the specific role as which you want to do the REVOKE. Failure to do so may lead to revoking privileges other than the ones you intended, or not revoking any privileges at all.

Use psql’s \dp meta-command to obtain information about existing privileges for tables and columns. There are other \d meta-commands that you can use to display the privileges of non-table objects.

Examples

Revoke insert privilege for the public on table films:

  1. REVOKE INSERT ON films FROM PUBLIC;

Revoke all privileges from role sally on view topten. Note that this actually means revoke all privileges that the current role granted (if not a superuser).

  1. REVOKE ALL PRIVILEGES ON topten FROM sally;

Revoke membership in role admins from user joe:

  1. REVOKE admins FROM joe;

Compatibility

The compatibility notes of the GRANT command also apply to REVOKE.

Either RESTRICT or CASCADE is required according to the standard, but Greenplum Database assumes RESTRICT by default.

See Also

GRANT

Parent topic: SQL Commands