先进入psql
切换到目标数据库
\c mydb
对于老表
grant usage on schema public to $read_only_user; grant select on all tables in schema public to $read_only_user;
设置默认,对于未创建的表直接默认赋予只读权限
alter default privileges for user $db_owner in schema public grant select on tables to $read_only_user;
pubic这个schema是默认的schema
测试建表语句
create table t2 ( id serial, name varchar(64) );
时间: 2024-10-05 17:12:45