数据库所有者无法授予选择

问题描述 投票:0回答:0

我希望拥有一个可以创建角色并为该数据库执行所有管理任务的数据库所有者。数据库所有者创建的所有角色必须对公共模式中的所有表具有选择权,并且拥有自己的模式,在其中拥有所有权限。 所以我正在努力:

\connect postgres postgres;
create role db_owner with createrole password 'passwd' login;
create database db with owner db_owner;
\connect db db_owner;
grant select on all tables in schema public to public;
create table t (i int);
create role s1 with password 's1' login;
grant s1 to db_owner;
create schema authorization s1;

现在,当我尝试

select from public.t
作为用户
s1
时,它被拒绝了:

\connect db s1;
db=> select * from t;
ERROR:  permission denied for table t

如果

grant select
是由
postgres
发出的,则有效:

db=> \connect db postgres
You are now connected to database "db" as user "postgres".
db=# grant select on all tables in schema public to public;
GRANT
db=# \connect db s1
You are now connected to database "db" as user "s1".
db=> select * from t;
 i 
---
(0 rows)

为什么数据库所有者

grant select
不能在
public
模式中?怎么办?

postgresql permissions schema roles sql-grant
© www.soinside.com 2019 - 2024. All rights reserved.