Alter default privileges for a group role in PostgreSQL

后端 未结 1 785
灰色年华
灰色年华 2020-12-25 14:37

I have created two group roles in Postgres 9.2: one is called admins and the other is called readers.

The idea is very simple: admins

相关标签:
1条回答
  • 2020-12-25 15:04

    If a user creates a table then this user becomes the owner of the table. So in your case any default privileges for userX apply, not those of admins. the solution is to SET ROLE admins before creating your table:

    SET ROLE admins;
    CREATE TABLE ... -- This now applies default privileges of admins
    ;
    RESET ROLE;
    

    More in general, you would want to do this always: Create all tables and views through a group role or some other role not used in daily operations and grant access to the relations to another group role whose privileges are inherited by regular login roles (users). This greatly facilitates security management.

    Cheers, Patrick

    0 讨论(0)
提交回复
热议问题