Skip to content
Advertisement

Grant privileges on future tables in PostgreSQL?

I am running PostgreSQL 9.3.1. I have test database and backup user which is used to backup the database. I have no problems with granting privileges to all current tables, but I have to grant privileges each time the new table is added to schema.

Is it possible to grant access to tables which will be created in future without making user owner of the table?

Advertisement

Answer

It looks like the solution is to alter default privileges for backup user:

From the comment by Matt Schaffer:

As caveat, the default only applies to the user that executed the alter statement. This confused me since I was driving most of my permissions statements from the postgres user but creating tables from an app user. In short, you might need something like this depending on your setup:

Where webapp is the user that will be creating new tables in the futrue and backup is the user that will be able to read from new tables created by webapp.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement