Grant privileges on future tables in PostgreSQL?

前端 未结 1 1379
长发绾君心
长发绾君心 2020-12-08 06:10

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 privileg

相关标签:
1条回答
  • 2020-12-08 07:03

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

    alter default privileges in schema public grant all on tables to backup;
    alter default privileges in schema public grant all on sequences to backup;
    

    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:

    ALTER DEFAULT PRIVILEGES FOR USER webapp IN SCHEMA public GRANT SELECT ON SEQUENCES TO backup;
    ALTER DEFAULT PRIVILEGES FOR USER webapp IN SCHEMA public GRANT SELECT ON TABLES TO backup;
    
    0 讨论(0)
提交回复
热议问题