1REVOKE() SQL Commands REVOKE()
2
3
4
6 REVOKE - remove access privileges
7
8
10 REVOKE [ GRANT OPTION FOR ]
11 { { SELECT | INSERT | UPDATE | DELETE | REFERENCES | TRIGGER }
12 [,...] | ALL [ PRIVILEGES ] }
13 ON [ TABLE ] tablename [, ...]
14 FROM { username | GROUP groupname | PUBLIC } [, ...]
15 [ CASCADE | RESTRICT ]
16
17 REVOKE [ GRANT OPTION FOR ]
18 { { USAGE | SELECT | UPDATE }
19 [,...] | ALL [ PRIVILEGES ] }
20 ON SEQUENCE sequencename [, ...]
21 FROM { username | GROUP groupname | PUBLIC } [, ...]
22 [ CASCADE | RESTRICT ]
23
24 REVOKE [ GRANT OPTION FOR ]
25 { { CREATE | CONNECT | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] }
26 ON DATABASE dbname [, ...]
27 FROM { username | GROUP groupname | PUBLIC } [, ...]
28 [ CASCADE | RESTRICT ]
29
30 REVOKE [ GRANT OPTION FOR ]
31 { EXECUTE | ALL [ PRIVILEGES ] }
32 ON FUNCTION funcname ( [ [ argmode ] [ argname ] argtype [, ...] ] ) [, ...]
33 FROM { username | GROUP groupname | PUBLIC } [, ...]
34 [ CASCADE | RESTRICT ]
35
36 REVOKE [ GRANT OPTION FOR ]
37 { USAGE | ALL [ PRIVILEGES ] }
38 ON LANGUAGE langname [, ...]
39 FROM { username | GROUP groupname | PUBLIC } [, ...]
40 [ CASCADE | RESTRICT ]
41
42 REVOKE [ GRANT OPTION FOR ]
43 { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
44 ON SCHEMA schemaname [, ...]
45 FROM { username | GROUP groupname | PUBLIC } [, ...]
46 [ CASCADE | RESTRICT ]
47
48 REVOKE [ GRANT OPTION FOR ]
49 { CREATE | ALL [ PRIVILEGES ] }
50 ON TABLESPACE tablespacename [, ...]
51 FROM { username | GROUP groupname | PUBLIC } [, ...]
52 [ CASCADE | RESTRICT ]
53
54 REVOKE [ ADMIN OPTION FOR ]
55 role [, ...] FROM username [, ...]
56 [ CASCADE | RESTRICT ]
57
58
60 The REVOKE command revokes previously granted privileges from one or
61 more roles. The key word PUBLIC refers to the implicitly defined group
62 of all roles.
63
64 See the description of the GRANT [grant(7)] command for the meaning of
65 the privilege types.
66
67 Note that any particular role will have the sum of privileges granted
68 directly to it, privileges granted to any role it is presently a member
69 of, and privileges granted to PUBLIC. Thus, for example, revoking
70 SELECT privilege from PUBLIC does not necessarily mean that all roles
71 have lost SELECT privilege on the object: those who have it granted
72 directly or via another role will still have it.
73
74 If GRANT OPTION FOR is specified, only the grant option for the privi‐
75 lege is revoked, not the privilege itself. Otherwise, both the privi‐
76 lege and the grant option are revoked.
77
78 If a user holds a privilege with grant option and has granted it to
79 other users then the privileges held by those other users are called
80 dependent privileges. If the privilege or the grant option held by the
81 first user is being revoked and dependent privileges exist, those
82 dependent privileges are also revoked if CASCADE is specified, else the
83 revoke action will fail. This recursive revocation only affects privi‐
84 leges that were granted through a chain of users that is traceable to
85 the user that is the subject of this REVOKE command. Thus, the
86 affected users may effectively keep the privilege if it was also
87 granted through other users.
88
89 When revoking membership in a role, GRANT OPTION is instead called
90 ADMIN OPTION, but the behavior is similar. Note also that this form of
91 the command does not allow the noise word GROUP.
92
94 Use psql(1)'s \z command to display the privileges granted on existing
95 objects. See GRANT [grant(7)] for information about the format.
96
97 A user can only revoke privileges that were granted directly by that
98 user. If, for example, user A has granted a privilege with grant option
99 to user B, and user B has in turned granted it to user C, then user A
100 cannot revoke the privilege directly from C. Instead, user A could
101 revoke the grant option from user B and use the CASCADE option so that
102 the privilege is in turn revoked from user C. For another example, if
103 both A and B have granted the same privilege to C, A can revoke his own
104 grant but not B's grant, so C will still effectively have the privi‐
105 lege.
106
107 When a non-owner of an object attempts to REVOKE privileges on the
108 object, the command will fail outright if the user has no privileges
109 whatsoever on the object. As long as some privilege is available, the
110 command will proceed, but it will revoke only those privileges for
111 which the user has grant options. The REVOKE ALL PRIVILEGES forms will
112 issue a warning message if no grant options are held, while the other
113 forms will issue a warning if grant options for any of the privileges
114 specifically named in the command are not held. (In principle these
115 statements apply to the object owner as well, but since the owner is
116 always treated as holding all grant options, the cases can never
117 occur.)
118
119 If a superuser chooses to issue a GRANT or REVOKE command, the command
120 is performed as though it were issued by the owner of the affected
121 object. Since all privileges ultimately come from the object owner
122 (possibly indirectly via chains of grant options), it is possible for a
123 superuser to revoke all privileges, but this may require use of CASCADE
124 as stated above.
125
126 REVOKE can also be done by a role that is not the owner of the affected
127 object, but is a member of the role that owns the object, or is a mem‐
128 ber of a role that holds privileges WITH GRANT OPTION on the object. In
129 this case the command is performed as though it were issued by the con‐
130 taining role that actually owns the object or holds the privileges WITH
131 GRANT OPTION. For example, if table t1 is owned by role g1, of which
132 role u1 is a member, then u1 can revoke privileges on t1 that are
133 recorded as being granted by g1. This would include grants made by u1
134 as well as by other members of role g1.
135
136 If the role executing REVOKE holds privileges indirectly via more than
137 one role membership path, it is unspecified which containing role will
138 be used to perform the command. In such cases it is best practice to
139 use SET ROLE to become the specific role you want to do the REVOKE as.
140 Failure to do so may lead to revoking privileges other than the ones
141 you intended, or not revoking anything at all.
142
144 Revoke insert privilege for the public on table films:
145
146 REVOKE INSERT ON films FROM PUBLIC;
147
148
149 Revoke all privileges from user manuel on view kinds:
150
151 REVOKE ALL PRIVILEGES ON kinds FROM manuel;
152
153 Note that this actually means ``revoke all privileges that I granted''.
154
155 Revoke membership in role admins from user joe:
156
157 REVOKE admins FROM joe;
158
159
161 The compatibility notes of the GRANT [grant(7)] command apply analo‐
162 gously to REVOKE. The syntax summary is:
163
164 REVOKE [ GRANT OPTION FOR ] privileges
165 ON object [ ( column [, ...] ) ]
166 FROM { PUBLIC | username [, ...] }
167 { RESTRICT | CASCADE }
168
169 One of RESTRICT or CASCADE is required according to the standard, but
170 PostgreSQL assumes RESTRICT by default.
171
173 GRANT [grant(7)]
174
175
176
177SQL - Language Statements 2008-06-08 REVOKE()