Create roles (users and group)CREATE ROLE ahmet LOGIN;CREATE ROLE samed LOGIN;CREATE ROLE mail_list_group;
GRANT mail_list_group TO ahmet;GRANT mail_list_group TO samed;
CREATE SCHEMA mail_listAUTHORIZATION mail_list_group;
ALTER DEFAULT PRIVILEGES FOR ROLE samed IN SCHEMA mail_listGRANT ALL ON TABLESTO mail_list_group WITH GRANT OPTION;ALTER DEFAULT PRIVILEGES FOR ROLE samed IN SCHEMA mail_listGRANT ALL ON SEQUENCESTO mail_list_group WITH GRANT OPTION;ALTER DEFAULT PRIVILEGES FOR ROLE samed IN SCHEMA mail_listGRANT ALL ON FUNCTIONSTO mail_list_group WITH GRANT OPTION;ALTER DEFAULT PRIVILEGES FOR ROLE ahmet IN SCHEMA mail_listGRANT ALL ON TABLESTO mail_list_group WITH GRANT OPTION;ALTER DEFAULT PRIVILEGES FOR ROLE ahmet IN SCHEMA mail_listGRANT ALL ON SEQUENCESTO mail_list_group WITH GRANT OPTION;ALTER DEFAULT PRIVILEGES FOR ROLE ahmet IN SCHEMA mail_listGRANT ALL ON FUNCTIONSTO mail_list_group WITH GRANT OPTION;
atp=> create table mail_list.t1 (c1 int);CREATE TABLEatp=> insert into t1 select generate_series(1,100);INSERT 0 100
atp=> select * from mail_list.t1 limit 5;c1----12345(5 rows)
atp=> drop table mail_list.t1;DROP TABLE
Hi,I would like to setup a new schema on an existing database and grant a set of users full control to the schema.I've done the following and would appreciate help as I'm not getting the behavior I was hoping for.I create a new group role and added members to the role then granted the role all privileges to the schema.When users create tables the table owner it set to the user instead of the role and I have to grant each newly created table before other members can access it.I've altered the default privileges however it seems to not have an effect. Someone pointed out that users would need to SET ROLE before creating tables, is this the only possible way or it there another way to achieve this?Thank you in advance