已经有多个主题与此主题相关。但是我无法完成它,并不断出现“权限被拒绝”错误。我一定做错了。
我的目标:在我想要的postgres数据库“ mydatabase”上
我如何尝试(大致):
psql -h /var/run/postgresql -p5433 -U postgres
create role group_x;
create role user_a LOGIN INHERIT PASSWORD <password>;
create role user_b LOGIN INHERIT PASSWORD <password>;
grant group_x to user_a;
grant group_x to user_b;
\connect mydatabase;
grant all on schema schema_x to group_x;
grant all on all tables in schema schema_x to group_x;
grant all on all sequences in schema schema_x to group_x;
grant all on all functions in schema schema_x to group_x;
set role group_x;
alter default privileges for role group_x in schema schema_x
grant all on tables to group_x;
alter default privileges for role group_x in schema schema_x
grant all on sequences to group_x;
alter default privileges for role group_x in schema schema_x
grant all on functions to group_x;
感谢您指出我的错误!
如果您是ALTER DEFAULT PRIVILEGES FOR ROLE group_x
,则意味着特权仅授予将来的对象由用户group_x
创建的对象。
因此您需要在FOR ROLE
子句中指定创建表的用户。