PostgreSQL 给角色授予只读权限 (1059 views)

gHOST

2019-12-10 11:29:59

场景

创建一个只读用户 readonly,将 db1 数据的所有表的只读权限赋予给 readonly 用户。

创建用户

postgres=# create user readonly with password 'password';

切换当前数据库

postgres=# \c db1
You are now connected to database "db1" as user "postgres".

给 readonly 用户授权

db1=# grant select  on all tables in schema public to readonly;

完成