1REVOKE(7) PostgreSQL 12.2 Documentation REVOKE(7)
2
3
4
6 REVOKE - remove access privileges
7
9 REVOKE [ GRANT OPTION FOR ]
10 { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
11 [, ...] | ALL [ PRIVILEGES ] }
12 ON { [ TABLE ] table_name [, ...]
13 | ALL TABLES IN SCHEMA schema_name [, ...] }
14 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
15 [ CASCADE | RESTRICT ]
16
17 REVOKE [ GRANT OPTION FOR ]
18 { { SELECT | INSERT | UPDATE | REFERENCES } ( column_name [, ...] )
19 [, ...] | ALL [ PRIVILEGES ] ( column_name [, ...] ) }
20 ON [ TABLE ] table_name [, ...]
21 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
22 [ CASCADE | RESTRICT ]
23
24 REVOKE [ GRANT OPTION FOR ]
25 { { USAGE | SELECT | UPDATE }
26 [, ...] | ALL [ PRIVILEGES ] }
27 ON { SEQUENCE sequence_name [, ...]
28 | ALL SEQUENCES IN SCHEMA schema_name [, ...] }
29 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
30 [ CASCADE | RESTRICT ]
31
32 REVOKE [ GRANT OPTION FOR ]
33 { { CREATE | CONNECT | TEMPORARY | TEMP } [, ...] | ALL [ PRIVILEGES ] }
34 ON DATABASE database_name [, ...]
35 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
36 [ CASCADE | RESTRICT ]
37
38 REVOKE [ GRANT OPTION FOR ]
39 { USAGE | ALL [ PRIVILEGES ] }
40 ON DOMAIN domain_name [, ...]
41 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
42 [ CASCADE | RESTRICT ]
43
44 REVOKE [ GRANT OPTION FOR ]
45 { USAGE | ALL [ PRIVILEGES ] }
46 ON FOREIGN DATA WRAPPER fdw_name [, ...]
47 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
48 [ CASCADE | RESTRICT ]
49
50 REVOKE [ GRANT OPTION FOR ]
51 { USAGE | ALL [ PRIVILEGES ] }
52 ON FOREIGN SERVER server_name [, ...]
53 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
54 [ CASCADE | RESTRICT ]
55
56 REVOKE [ GRANT OPTION FOR ]
57 { EXECUTE | ALL [ PRIVILEGES ] }
58 ON { { FUNCTION | PROCEDURE | ROUTINE } function_name [ ( [ [ argmode ] [ arg_name ] arg_type [, ...] ] ) ] [, ...]
59 | ALL { FUNCTIONS | PROCEDURES | ROUTINES } IN SCHEMA schema_name [, ...] }
60 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
61 [ CASCADE | RESTRICT ]
62
63 REVOKE [ GRANT OPTION FOR ]
64 { USAGE | ALL [ PRIVILEGES ] }
65 ON LANGUAGE lang_name [, ...]
66 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
67 [ CASCADE | RESTRICT ]
68
69 REVOKE [ GRANT OPTION FOR ]
70 { { SELECT | UPDATE } [, ...] | ALL [ PRIVILEGES ] }
71 ON LARGE OBJECT loid [, ...]
72 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
73 [ CASCADE | RESTRICT ]
74
75 REVOKE [ GRANT OPTION FOR ]
76 { { CREATE | USAGE } [, ...] | ALL [ PRIVILEGES ] }
77 ON SCHEMA schema_name [, ...]
78 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
79 [ CASCADE | RESTRICT ]
80
81 REVOKE [ GRANT OPTION FOR ]
82 { CREATE | ALL [ PRIVILEGES ] }
83 ON TABLESPACE tablespace_name [, ...]
84 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
85 [ CASCADE | RESTRICT ]
86
87 REVOKE [ GRANT OPTION FOR ]
88 { USAGE | ALL [ PRIVILEGES ] }
89 ON TYPE type_name [, ...]
90 FROM { [ GROUP ] role_name | PUBLIC } [, ...]
91 [ CASCADE | RESTRICT ]
92
93 REVOKE [ ADMIN OPTION FOR ]
94 role_name [, ...] FROM role_name [, ...]
95 [ CASCADE | RESTRICT ]
96
98 The REVOKE command revokes previously granted privileges from one or
99 more roles. The key word PUBLIC refers to the implicitly defined group
100 of all roles.
101
102 See the description of the GRANT(7) command for the meaning of the
103 privilege types.
104
105 Note that any particular role will have the sum of privileges granted
106 directly to it, privileges granted to any role it is presently a member
107 of, and privileges granted to PUBLIC. Thus, for example, revoking
108 SELECT privilege from PUBLIC does not necessarily mean that all roles
109 have lost SELECT privilege on the object: those who have it granted
110 directly or via another role will still have it. Similarly, revoking
111 SELECT from a user might not prevent that user from using SELECT if
112 PUBLIC or another membership role still has SELECT rights.
113
114 If GRANT OPTION FOR is specified, only the grant option for the
115 privilege is revoked, not the privilege itself. Otherwise, both the
116 privilege and the grant option are revoked.
117
118 If a user holds a privilege with grant option and has granted it to
119 other users then the privileges held by those other users are called
120 dependent privileges. If the privilege or the grant option held by the
121 first user is being revoked and dependent privileges exist, those
122 dependent privileges are also revoked if CASCADE is specified; if it is
123 not, the revoke action will fail. This recursive revocation only
124 affects privileges that were granted through a chain of users that is
125 traceable to the user that is the subject of this REVOKE command. Thus,
126 the affected users might effectively keep the privilege if it was also
127 granted through other users.
128
129 When revoking privileges on a table, the corresponding column
130 privileges (if any) are automatically revoked on each column of the
131 table, as well. On the other hand, if a role has been granted
132 privileges on a table, then revoking the same privileges from
133 individual columns will have no effect.
134
135 When revoking membership in a role, GRANT OPTION is instead called
136 ADMIN OPTION, but the behavior is similar. Note also that this form of
137 the command does not allow the noise word GROUP.
138
140 A user can only revoke privileges that were granted directly by that
141 user. If, for example, user A has granted a privilege with grant option
142 to user B, and user B has in turn granted it to user C, then user A
143 cannot revoke the privilege directly from C. Instead, user A could
144 revoke the grant option from user B and use the CASCADE option so that
145 the privilege is in turn revoked from user C. For another example, if
146 both A and B have granted the same privilege to C, A can revoke their
147 own grant but not B's grant, so C will still effectively have the
148 privilege.
149
150 When a non-owner of an object attempts to REVOKE privileges on the
151 object, the command will fail outright if the user has no privileges
152 whatsoever on the object. As long as some privilege is available, the
153 command will proceed, but it will revoke only those privileges for
154 which the user has grant options. The REVOKE ALL PRIVILEGES forms will
155 issue a warning message if no grant options are held, while the other
156 forms will issue a warning if grant options for any of the privileges
157 specifically named in the command are not held. (In principle these
158 statements apply to the object owner as well, but since the owner is
159 always treated as holding all grant options, the cases can never
160 occur.)
161
162 If a superuser chooses to issue a GRANT or REVOKE command, the command
163 is performed as though it were issued by the owner of the affected
164 object. Since all privileges ultimately come from the object owner
165 (possibly indirectly via chains of grant options), it is possible for a
166 superuser to revoke all privileges, but this might require use of
167 CASCADE as stated above.
168
169 REVOKE can also be done by a role that is not the owner of the affected
170 object, but is a member of the role that owns the object, or is a
171 member of a role that holds privileges WITH GRANT OPTION on the object.
172 In this case the command is performed as though it were issued by the
173 containing role that actually owns the object or holds the privileges
174 WITH GRANT OPTION. For example, if table t1 is owned by role g1, of
175 which role u1 is a member, then u1 can revoke privileges on t1 that are
176 recorded as being granted by g1. This would include grants made by u1
177 as well as by other members of role g1.
178
179 If the role executing REVOKE holds privileges indirectly via more than
180 one role membership path, it is unspecified which containing role will
181 be used to perform the command. In such cases it is best practice to
182 use SET ROLE to become the specific role you want to do the REVOKE as.
183 Failure to do so might lead to revoking privileges other than the ones
184 you intended, or not revoking anything at all.
185
186 See Section 5.7 for more information about specific privilege types, as
187 well as how to inspect objects' privileges.
188
190 Revoke insert privilege for the public on table films:
191
192 REVOKE INSERT ON films FROM PUBLIC;
193
194 Revoke all privileges from user manuel on view kinds:
195
196 REVOKE ALL PRIVILEGES ON kinds FROM manuel;
197
198 Note that this actually means “revoke all privileges that I granted”.
199
200 Revoke membership in role admins from user joe:
201
202 REVOKE admins FROM joe;
203
205 The compatibility notes of the GRANT(7) command apply analogously to
206 REVOKE. The keyword RESTRICT or CASCADE is required according to the
207 standard, but PostgreSQL assumes RESTRICT by default.
208
210 GRANT(7), ALTER DEFAULT PRIVILEGES (ALTER_DEFAULT_PRIVILEGES(7))
211
212
213
214PostgreSQL 12.2 2020 REVOKE(7)