REVOKE

Synopsis

Use the REVOKE statement to remove access privileges from one or more roles.

Syntax

  1. revoke_table ::= REVOKE [ GRANT OPTION FOR ]
  2. { { SELECT
  3. | INSERT
  4. | UPDATE
  5. | DELETE
  6. | TRUNCATE
  7. | REFERENCES
  8. | TRIGGER } [ , ... ]
  9. | ALL [ PRIVILEGES ] } ON
  10. { [ TABLE ] table_name [ , ... ]
  11. | ALL TABLES IN SCHEMA schema_name [ , ... ] } FROM
  12. { [ GROUP ] role_name | PUBLIC } [ , ... ]
  13. [ CASCADE | RESTRICT ]
  14. revoke_table_col ::= REVOKE [ GRANT OPTION FOR ]
  15. { { SELECT | INSERT | UPDATE | REFERENCES } (
  16. column_names ) [ ,(column_names ... ]
  17. | ALL [ PRIVILEGES ] ( column_names ) } ON
  18. [ TABLE ] table_name [ , ... ] FROM
  19. { [ GROUP ] role_name | PUBLIC } [ , ... ]
  20. [ CASCADE | RESTRICT ]
  21. revoke_seq ::= REVOKE [ GRANT OPTION FOR ]
  22. { { USAGE | SELECT | UPDATE } [ , ... ]
  23. | ALL [ PRIVILEGES ] } ON
  24. { SEQUENCE sequence_name [ , ... ]
  25. | ALL SEQUENCES IN SCHEMA schema_name [ , ... ] }
  26. FROM { [ GROUP ] role_name | PUBLIC } [ , ... ]
  27. [ CASCADE | RESTRICT ]
  28. revoke_db ::= REVOKE [ GRANT OPTION FOR ]
  29. { { CREATE | CONNECT | TEMPORARY | TEMP } [ , ... ]
  30. | ALL [ PRIVILEGES ] } ON DATABASE database_name
  31. [ , ... ] FROM { [ GROUP ] role_name | PUBLIC }
  32. [ , ... ] [ CASCADE | RESTRICT ]
  33. revoke_domain ::= REVOKE [ GRANT OPTION FOR ]
  34. { USAGE | ALL [ PRIVILEGES ] } ON DOMAIN domain_name
  35. [ , ... ] FROM { [ GROUP ] role_name | PUBLIC }
  36. [ , ... ] [ CASCADE | RESTRICT ]
  37. revoke_schema ::= REVOKE [ GRANT OPTION FOR ]
  38. { { CREATE | USAGE } [ , ... ]
  39. | ALL [ PRIVILEGES ] } ON SCHEMA schema_name
  40. [ , ... ] FROM { [ GROUP ] role_name | PUBLIC }
  41. [ , ... ] [ CASCADE | RESTRICT ]
  42. revoke_type ::= REVOKE [ GRANT OPTION FOR ]
  43. { USAGE | ALL [ PRIVILEGES ] } ON TYPE type_name
  44. [ , ... ] FROM { [ GROUP ] role_name | PUBLIC }
  45. [ , ... ] [ CASCADE | RESTRICT ]
  46. revoke_role ::= REVOKE [ ADMIN OPTION FOR ] role_name [ , ... ] FROM
  47. role_name [ , ... ] [ CASCADE | RESTRICT ]

revoke_table

REVOKE - 图1

revoke_table_col

REVOKE - 图2

revoke_seq

REVOKE - 图3

revoke_db

REVOKE - 图4

revoke_domain

REVOKE - 图5

revoke_schema

REVOKE - 图6

revoke_type

REVOKE - 图7

revoke_role

REVOKE - 图8

Semantics

Any role has the sum of all privileges assigned to it. So, if REVOKE is used to revoke SELECT from PUBLIC, then it does not mean that all roles have lost SELECT privilege.If a role had SELECT granted directly to it or inherited it via a group, then it can continue to hold the SELECT privilege.

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.

Similarly, while revoking a role, if ADMIN OPTION FOR is specified, then only the admin option for the privilege is revoked.

If a user holds a privilege with grant option and has granted it to other users, then revoking the privilege from the first user will also revoke it from dependent usersif CASCADE is specified. Otherwise, the REVOKE will fail.

When revoking privileges on a table, the corresponding column privileges (if any) are automatically revoked 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.

Examples

  • Revoke SELECT privilege for PUBLIC on table ‘stores’
  1. yugabyte=# REVOKE SELECT ON stores FROM PUBLIC;
  • Remove user John from SysAdmins group.
  1. yugabyte=# REVOKE SysAdmins FROM John;

See also