PostgreSQL privilege grant not visible

后端 未结 1 1092
你的背包
你的背包 2021-01-27 14:58

On PostgreSQL 10, I\'ve a schema called tn_schema and a database called tn_beta_db. I think so, although I do have to be connected to the relevant dat

相关标签:
1条回答
  • 2021-01-27 15:18

    A list of things you misunderstood:

    1. ALTER DEFAULT PRIVILEGES does not change the permissions on any existing object, in your case the schema.

      You need to grant the CREATE privilege on the schema:

      GRANT CREATE ON SCHEMA tn_schema TO tn_beta_migrator;
      
    2. The ALTER DEFAULT PRIVILEGES statement you ran will only affect the permissions on tables created by user postgres in schema tn_schema, but it seems that you want tn_beta_migrator to create tables.

      You don't need ALTER DEFAULT PRIVILEGES at all, since the user that creates the table becomes the table owner and has all privileges on the table by default.

    3. You can view default privileges with \ddp in psql.

    4. Schemas are part of a database, so you need to connect to the database to see its schemas.

    If you want that the tables created by tn_beta_migrator get certain permissions by default, you must define default privileges for that user (and not for postgres, like you did):

    ALTER DEFAULT PRIVILEGES FOR ROLE tn_beta_migrator IN SCHEMA tn_schema GRANT ...;
    
    0 讨论(0)
提交回复
热议问题