我需要帮助创建两个 Postgres 用户,一个是只读的,另一个是读写的,包括创建只读用户可以选择的新表。
以下是我作为管理员用户使用的命令,满足读写用户的要求,但不满足只读用户的要求。 问题是只读用户无法读取读写用户创建的新表。 我做错了什么?
> create database portal;
> \c portal
> revoke create on schema public from public;
> revoke all on database portal from public;
> create role portal_reader noinherit;
> grant connect on database portal to portal_reader;
> grant usage on schema public to portal_reader;
> grant select on all tables in schema public to portal_reader;
> alter default privileges in schema public grant select on tables to portal_reader;
> grant portal_reader to portal_ro;
> create role portal_writer noinherit;
> grant connect on database portal to portal_writer;
> grant all on schema public to portal_writer;
> grant all on all tables in schema public to portal_writer;
> alter default privileges in schema public grant all on tables to portal_writer;
> grant all on all sequences in schema public to portal_writer;
> alter default privileges in schema public grant all on sequences to portal_writer;
> grant portal_writer to portal;