1ALTER DEFAULT PRIVILEGES(P7o)stgreSQL 9.2.24 DocumentatAiLoTnER DEFAULT PRIVILEGES(7)
2
3
4

NAME

6       ALTER_DEFAULT_PRIVILEGES - define default access privileges
7

SYNOPSIS

9       ALTER DEFAULT PRIVILEGES
10           [ FOR { ROLE | USER } target_role [, ...] ]
11           [ IN SCHEMA schema_name [, ...] ]
12           abbreviated_grant_or_revoke
13
14       where abbreviated_grant_or_revoke is one of:
15
16       GRANT { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
17           [, ...] | ALL [ PRIVILEGES ] }
18           ON TABLES
19           TO { [ GROUP ] role_name | PUBLIC } [, ...] [ WITH GRANT OPTION ]
20
21       GRANT { { USAGE | SELECT | UPDATE }
22           [, ...] | ALL [ PRIVILEGES ] }
23           ON SEQUENCES
24           TO { [ GROUP ] role_name | PUBLIC } [, ...] [ WITH GRANT OPTION ]
25
26       GRANT { EXECUTE | ALL [ PRIVILEGES ] }
27           ON FUNCTIONS
28           TO { [ GROUP ] role_name | PUBLIC } [, ...] [ WITH GRANT OPTION ]
29
30       GRANT { USAGE | ALL [ PRIVILEGES ] }
31           ON TYPES
32           TO { [ GROUP ] role_name | PUBLIC } [, ...] [ WITH GRANT OPTION ]
33
34       REVOKE [ GRANT OPTION FOR ]
35           { { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
36           [, ...] | ALL [ PRIVILEGES ] }
37           ON TABLES
38           FROM { [ GROUP ] role_name | PUBLIC } [, ...]
39           [ CASCADE | RESTRICT ]
40
41       REVOKE [ GRANT OPTION FOR ]
42           { { USAGE | SELECT | UPDATE }
43           [, ...] | ALL [ PRIVILEGES ] }
44           ON SEQUENCES
45           FROM { [ GROUP ] role_name | PUBLIC } [, ...]
46           [ CASCADE | RESTRICT ]
47
48       REVOKE [ GRANT OPTION FOR ]
49           { EXECUTE | ALL [ PRIVILEGES ] }
50           ON FUNCTIONS
51           FROM { [ GROUP ] role_name | PUBLIC } [, ...]
52           [ CASCADE | RESTRICT ]
53
54       REVOKE [ GRANT OPTION FOR ]
55           { USAGE | ALL [ PRIVILEGES ] }
56           ON TYPES
57           FROM { [ GROUP ] role_name | PUBLIC } [, ...]
58           [ CASCADE | RESTRICT ]
59

DESCRIPTION

61       ALTER DEFAULT PRIVILEGES allows you to set the privileges that will be
62       applied to objects created in the future. (It does not affect
63       privileges assigned to already-existing objects.) Currently, only the
64       privileges for tables (including views and foreign tables), sequences,
65       functions, and types (including domains) can be altered.
66
67       You can change default privileges only for objects that will be created
68       by yourself or by roles that you are a member of. The privileges can be
69       set globally (i.e., for all objects created in the current database),
70       or just for objects created in specified schemas. Default privileges
71       that are specified per-schema are added to whatever the global default
72       privileges are for the particular object type.
73
74       As explained under GRANT(7), the default privileges for any object type
75       normally grant all grantable permissions to the object owner, and may
76       grant some privileges to PUBLIC as well. However, this behavior can be
77       changed by altering the global default privileges with ALTER DEFAULT
78       PRIVILEGES.
79
80   Parameters
81       target_role
82           The name of an existing role of which the current role is a member.
83           If FOR ROLE is omitted, the current role is assumed.
84
85       schema_name
86           The name of an existing schema. If specified, the default
87           privileges are altered for objects later created in that schema. If
88           IN SCHEMA is omitted, the global default privileges are altered.
89
90       role_name
91           The name of an existing role to grant or revoke privileges for.
92           This parameter, and all the other parameters in
93           abbreviated_grant_or_revoke, act as described under GRANT(7) or
94           REVOKE(7), except that one is setting permissions for a whole class
95           of objects rather than specific named objects.
96

NOTES

98       Use psql(1)'s \ddp command to obtain information about existing
99       assignments of default privileges. The meaning of the privilege values
100       is the same as explained for \dp under GRANT(7).
101
102       If you wish to drop a role for which the default privileges have been
103       altered, it is necessary to reverse the changes in its default
104       privileges or use DROP OWNED BY to get rid of the default privileges
105       entry for the role.
106

EXAMPLES

108       Grant SELECT privilege to everyone for all tables (and views) you
109       subsequently create in schema myschema, and allow role webuser to
110       INSERT into them too:
111
112           ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ON TABLES TO PUBLIC;
113           ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT INSERT ON TABLES TO webuser;
114
115       Undo the above, so that subsequently-created tables won't have any more
116       permissions than normal:
117
118           ALTER DEFAULT PRIVILEGES IN SCHEMA myschema REVOKE SELECT ON TABLES FROM PUBLIC;
119           ALTER DEFAULT PRIVILEGES IN SCHEMA myschema REVOKE INSERT ON TABLES FROM webuser;
120
121       Remove the public EXECUTE permission that is normally granted on
122       functions, for all functions subsequently created by role admin:
123
124           ALTER DEFAULT PRIVILEGES FOR ROLE admin REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;
125

COMPATIBILITY

127       There is no ALTER DEFAULT PRIVILEGES statement in the SQL standard.
128

SEE ALSO

130       GRANT(7), REVOKE(7)
131
132
133
134PostgreSQL 9.2.24                 2017-11-06       ALTER DEFAULT PRIVILEGES(7)
Impressum