Description
allows you to set the privileges that will be applied to objects created in the future. (It does not affect privileges assigned to already-existing objects.) Currently, only the privileges for tables (including views and foreign tables), sequences, functions, and types (including domains) can be altered.
You can change default privileges only for objects that will be created by yourself or by roles that you are a member of. The privileges can be set globally (i.e., for all objects created in the current database), or just for objects created in specified schemas. Default privileges that are specified per-schema are added to whatever the global default privileges are for the particular object type.
As explained under GRANT, the default privileges for any object type normally grant all grantable permissions to the object owner, and may grant some privileges to PUBLIC
as well. However, this behavior can be changed by altering the global default privileges with ALTER DEFAULT PRIVILEGES
.
target_role
The name of an existing role of which the current role is a member. If FOR ROLE
is omitted, the current role is assumed.
The name of an existing schema. If specified, the default privileges are altered for objects later created in that schema. If is omitted, the global default privileges are altered.
role_name
The name of an existing role to grant or revoke privileges for. This parameter, and all the other parameters in abbreviated_grant_or_revoke, act as described under GRANT or , except that one is setting permissions for a whole class of objects rather than specific named objects.
Notes
Use ’s \ddp
command to obtain information about existing assignments of default privileges. The meaning of the privilege values is the same as explained for \dp
under GRANT.
If you wish to drop a role for which the default privileges have been altered, it is necessary to reverse the changes in its default privileges or use DROP OWNED BY
to get rid of the default privileges entry for the role.
Undo the above, so that subsequently-created tables won’t have any more permissions than normal:
Remove the public EXECUTE permission that is normally granted on functions, for all functions subsequently created by role admin
:
Compatibility
There is no ALTER DEFAULT PRIVILEGES
statement in the SQL standard.
Parent topic: SQL Commands