4

According to the PostgreSQL documentation on ALTER DEFAULT PRIVILEGES, default privileges can be set on tables, sequences, functions, types.

Is there any way to set default privileges on schemas themselves, so that the privileges specified in the GRANT clause are by default applied to any new schema in the database upon its creation?

3

As mentioned by @a_horse_with_no_name, this is now implemented in PostgreSQL v10

ALTER DEFAULT PRIVILEGES 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 schemas, tables (including views and foreign tables), sequences, functions, and types (including domains) can be altered.

Example,

ALTER DEFAULT PRIVILEGES
  GRANT USAGE ON SCHEMAS
  TO role;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.