]> begriffs open source - ai-pg/blob - full-docs/man7/REVOKE.7
Include links to all subsection html pages, with shorter paths too
[ai-pg] / full-docs / man7 / REVOKE.7
1 '\" t
2 .\"     Title: REVOKE
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "REVOKE" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 REVOKE \- remove access privileges
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 REVOKE [ GRANT OPTION FOR ]
36     { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER | MAINTAIN }
37     [, \&.\&.\&.] | ALL [ PRIVILEGES ] }
38     ON { [ TABLE ] \fItable_name\fR [, \&.\&.\&.]
39          | ALL TABLES IN SCHEMA \fIschema_name\fR [, \&.\&.\&.] }
40     FROM \fIrole_specification\fR [, \&.\&.\&.]
41     [ GRANTED BY \fIrole_specification\fR ]
42     [ CASCADE | RESTRICT ]
43
44 REVOKE [ GRANT OPTION FOR ]
45     { { SELECT | INSERT | UPDATE | REFERENCES } ( \fIcolumn_name\fR [, \&.\&.\&.] )
46     [, \&.\&.\&.] | ALL [ PRIVILEGES ] ( \fIcolumn_name\fR [, \&.\&.\&.] ) }
47     ON [ TABLE ] \fItable_name\fR [, \&.\&.\&.]
48     FROM \fIrole_specification\fR [, \&.\&.\&.]
49     [ GRANTED BY \fIrole_specification\fR ]
50     [ CASCADE | RESTRICT ]
51
52 REVOKE [ GRANT OPTION FOR ]
53     { { USAGE | SELECT | UPDATE }
54     [, \&.\&.\&.] | ALL [ PRIVILEGES ] }
55     ON { SEQUENCE \fIsequence_name\fR [, \&.\&.\&.]
56          | ALL SEQUENCES IN SCHEMA \fIschema_name\fR [, \&.\&.\&.] }
57     FROM \fIrole_specification\fR [, \&.\&.\&.]
58     [ GRANTED BY \fIrole_specification\fR ]
59     [ CASCADE | RESTRICT ]
60
61 REVOKE [ GRANT OPTION FOR ]
62     { { CREATE | CONNECT | TEMPORARY | TEMP } [, \&.\&.\&.] | ALL [ PRIVILEGES ] }
63     ON DATABASE \fIdatabase_name\fR [, \&.\&.\&.]
64     FROM \fIrole_specification\fR [, \&.\&.\&.]
65     [ GRANTED BY \fIrole_specification\fR ]
66     [ CASCADE | RESTRICT ]
67
68 REVOKE [ GRANT OPTION FOR ]
69     { USAGE | ALL [ PRIVILEGES ] }
70     ON DOMAIN \fIdomain_name\fR [, \&.\&.\&.]
71     FROM \fIrole_specification\fR [, \&.\&.\&.]
72     [ GRANTED BY \fIrole_specification\fR ]
73     [ CASCADE | RESTRICT ]
74
75 REVOKE [ GRANT OPTION FOR ]
76     { USAGE | ALL [ PRIVILEGES ] }
77     ON FOREIGN DATA WRAPPER \fIfdw_name\fR [, \&.\&.\&.]
78     FROM \fIrole_specification\fR [, \&.\&.\&.]
79     [ GRANTED BY \fIrole_specification\fR ]
80     [ CASCADE | RESTRICT ]
81
82 REVOKE [ GRANT OPTION FOR ]
83     { USAGE | ALL [ PRIVILEGES ] }
84     ON FOREIGN SERVER \fIserver_name\fR [, \&.\&.\&.]
85     FROM \fIrole_specification\fR [, \&.\&.\&.]
86     [ GRANTED BY \fIrole_specification\fR ]
87     [ CASCADE | RESTRICT ]
88
89 REVOKE [ GRANT OPTION FOR ]
90     { EXECUTE | ALL [ PRIVILEGES ] }
91     ON { { FUNCTION | PROCEDURE | ROUTINE } \fIfunction_name\fR [ ( [ [ \fIargmode\fR ] [ \fIarg_name\fR ] \fIarg_type\fR [, \&.\&.\&.] ] ) ] [, \&.\&.\&.]
92          | ALL { FUNCTIONS | PROCEDURES | ROUTINES } IN SCHEMA \fIschema_name\fR [, \&.\&.\&.] }
93     FROM \fIrole_specification\fR [, \&.\&.\&.]
94     [ GRANTED BY \fIrole_specification\fR ]
95     [ CASCADE | RESTRICT ]
96
97 REVOKE [ GRANT OPTION FOR ]
98     { USAGE | ALL [ PRIVILEGES ] }
99     ON LANGUAGE \fIlang_name\fR [, \&.\&.\&.]
100     FROM \fIrole_specification\fR [, \&.\&.\&.]
101     [ GRANTED BY \fIrole_specification\fR ]
102     [ CASCADE | RESTRICT ]
103
104 REVOKE [ GRANT OPTION FOR ]
105     { { SELECT | UPDATE } [, \&.\&.\&.] | ALL [ PRIVILEGES ] }
106     ON LARGE OBJECT \fIloid\fR [, \&.\&.\&.]
107     FROM \fIrole_specification\fR [, \&.\&.\&.]
108     [ GRANTED BY \fIrole_specification\fR ]
109     [ CASCADE | RESTRICT ]
110
111 REVOKE [ GRANT OPTION FOR ]
112     { { SET | ALTER SYSTEM } [, \&.\&.\&.] | ALL [ PRIVILEGES ] }
113     ON PARAMETER \fIconfiguration_parameter\fR [, \&.\&.\&.]
114     FROM \fIrole_specification\fR [, \&.\&.\&.]
115     [ GRANTED BY \fIrole_specification\fR ]
116     [ CASCADE | RESTRICT ]
117
118 REVOKE [ GRANT OPTION FOR ]
119     { { CREATE | USAGE } [, \&.\&.\&.] | ALL [ PRIVILEGES ] }
120     ON SCHEMA \fIschema_name\fR [, \&.\&.\&.]
121     FROM \fIrole_specification\fR [, \&.\&.\&.]
122     [ GRANTED BY \fIrole_specification\fR ]
123     [ CASCADE | RESTRICT ]
124
125 REVOKE [ GRANT OPTION FOR ]
126     { CREATE | ALL [ PRIVILEGES ] }
127     ON TABLESPACE \fItablespace_name\fR [, \&.\&.\&.]
128     FROM \fIrole_specification\fR [, \&.\&.\&.]
129     [ GRANTED BY \fIrole_specification\fR ]
130     [ CASCADE | RESTRICT ]
131
132 REVOKE [ GRANT OPTION FOR ]
133     { USAGE | ALL [ PRIVILEGES ] }
134     ON TYPE \fItype_name\fR [, \&.\&.\&.]
135     FROM \fIrole_specification\fR [, \&.\&.\&.]
136     [ GRANTED BY \fIrole_specification\fR ]
137     [ CASCADE | RESTRICT ]
138
139 REVOKE [ { ADMIN | INHERIT | SET } OPTION FOR ]
140     \fIrole_name\fR [, \&.\&.\&.] FROM \fIrole_specification\fR [, \&.\&.\&.]
141     [ GRANTED BY \fIrole_specification\fR ]
142     [ CASCADE | RESTRICT ]
143
144 where \fIrole_specification\fR can be:
145
146     [ GROUP ] \fIrole_name\fR
147   | PUBLIC
148   | CURRENT_ROLE
149   | CURRENT_USER
150   | SESSION_USER
151 .fi
152 .SH "DESCRIPTION"
153 .PP
154 The
155 \fBREVOKE\fR
156 command revokes previously granted privileges from one or more roles\&. The key word
157 PUBLIC
158 refers to the implicitly defined group of all roles\&.
159 .PP
160 See the description of the
161 \fBGRANT\fR
162 command for the meaning of the privilege types\&.
163 .PP
164 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
165 PUBLIC\&. Thus, for example, revoking
166 SELECT
167 privilege from
168 PUBLIC
169 does not necessarily mean that all roles have lost
170 SELECT
171 privilege on the object: those who have it granted directly or via another role will still have it\&. Similarly, revoking
172 SELECT
173 from a user might not prevent that user from using
174 SELECT
175 if
176 PUBLIC
177 or another membership role still has
178 SELECT
179 rights\&.
180 .PP
181 If
182 GRANT OPTION FOR
183 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\&.
184 .PP
185 If a user holds a privilege with grant option and has granted it to other users then the privileges held by those other users are called dependent privileges\&. If the privilege or the grant option held by the first user is being revoked and dependent privileges exist, those dependent privileges are also revoked if
186 CASCADE
187 is specified; if it is not, the revoke action will fail\&. This recursive revocation only affects privileges that were granted through a chain of users that is traceable to the user that is the subject of this
188 REVOKE
189 command\&. Thus, the affected users might effectively keep the privilege if it was also granted through other users\&.
190 .PP
191 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\&.
192 .PP
193 When revoking membership in a role,
194 GRANT OPTION
195 is instead called
196 ADMIN OPTION, but the behavior is similar\&. Note that, in releases prior to
197 PostgreSQL
198 16, dependent privileges were not tracked for grants of role membership, and thus
199 CASCADE
200 had no effect for role membership\&. This is no longer the case\&. Note also that this form of the command does not allow the noise word
201 GROUP
202 in
203 \fIrole_specification\fR\&.
204 .PP
205 Just as
206 ADMIN OPTION
207 can be removed from an existing role grant, it is also possible to revoke
208 INHERIT OPTION
209 or
210 SET OPTION\&. This is equivalent to setting the value of the corresponding option to
211 FALSE\&.
212 .SH "NOTES"
213 .PP
214 A user can only revoke privileges that were granted directly by that user\&. If, for example, user A has granted 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
215 CASCADE
216 option so that the privilege is in turn revoked from user C\&. For another example, if both A and B have granted the same privilege to C, A can revoke their own grant but not B\*(Aqs grant, so C will still effectively have the privilege\&.
217 .PP
218 When a non\-owner of an object attempts to
219 \fBREVOKE\fR
220 privileges on the object, the command will fail outright if the user has no privileges whatsoever on the object\&. As long as some privilege is available, the command will proceed, but it will revoke only those privileges for which the user has grant options\&. The
221 \fBREVOKE ALL PRIVILEGES\fR
222 forms will issue a warning message if no grant options are held, while the other forms will 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 the owner is always treated as holding all grant options, the cases can never occur\&.)
223 .PP
224 If a superuser chooses to issue a
225 \fBGRANT\fR
226 or
227 \fBREVOKE\fR
228 command, the command is performed as though it were issued by the owner of the affected object\&. (Since roles do not have owners, in the case of a
229 \fBGRANT\fR
230 of role membership, the command is performed as though it were issued by the bootstrap superuser\&.) 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
231 CASCADE
232 as stated above\&.
233 .PP
234 \fBREVOKE\fR
235 can also be done 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
236 WITH GRANT OPTION
237 on the object\&. In this case the command is performed as though it were issued by the containing role that actually owns the object or holds the privileges
238 WITH GRANT OPTION\&. For example, if table
239 t1
240 is owned by role
241 g1, of which role
242 u1
243 is a member, then
244 u1
245 can revoke privileges on
246 t1
247 that are recorded as being granted by
248 g1\&. This would include grants made by
249 u1
250 as well as by other members of role
251 g1\&.
252 .PP
253 If the role executing
254 \fBREVOKE\fR
255 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
256 \fBSET ROLE\fR
257 to become the specific role you want to do the
258 \fBREVOKE\fR
259 as\&. Failure to do so might lead to revoking privileges other than the ones you intended, or not revoking anything at all\&.
260 .PP
261 See
262 Section\ \&5.8
263 for more information about specific privilege types, as well as how to inspect objects\*(Aq privileges\&.
264 .SH "EXAMPLES"
265 .PP
266 Revoke insert privilege for the public on table
267 films:
268 .sp
269 .if n \{\
270 .RS 4
271 .\}
272 .nf
273 REVOKE INSERT ON films FROM PUBLIC;
274 .fi
275 .if n \{\
276 .RE
277 .\}
278 .PP
279 Revoke all privileges from user
280 manuel
281 on view
282 kinds:
283 .sp
284 .if n \{\
285 .RS 4
286 .\}
287 .nf
288 REVOKE ALL PRIVILEGES ON kinds FROM manuel;
289 .fi
290 .if n \{\
291 .RE
292 .\}
293 .sp
294 Note that this actually means
295 \(lqrevoke all privileges that I granted\(rq\&.
296 .PP
297 Revoke membership in role
298 admins
299 from user
300 joe:
301 .sp
302 .if n \{\
303 .RS 4
304 .\}
305 .nf
306 REVOKE admins FROM joe;
307 .fi
308 .if n \{\
309 .RE
310 .\}
311 .SH "COMPATIBILITY"
312 .PP
313 The compatibility notes of the
314 \fBGRANT\fR
315 command apply analogously to
316 \fBREVOKE\fR\&. The keyword
317 RESTRICT
318 or
319 CASCADE
320 is required according to the standard, but
321 PostgreSQL
322 assumes
323 RESTRICT
324 by default\&.
325 .SH "SEE ALSO"
326 \fBGRANT\fR(7), ALTER DEFAULT PRIVILEGES (\fBALTER_DEFAULT_PRIVILEGES\fR(7))