PG数据库如何新建只读用户

一 新建全局只读账号
以超级用户登录数据库,创建用户。
create user test password 'test' superuser;
设置为只读transaction
alter role test set default_transaction_read_only=true;

二 新建单个schema只读账号
以超级用户登录数据库,创建用户。
create user readonly password 'readonly';
设置为只读transaction
alter user readonly set default_transaction_read_only=on;
默认postgres数据库public模式下的对象是可以访问的。
访问postgres数据库的schema
赋给使用schema的权限
grant usage on schema pg_toast to read_only;
添加所有表的只读权限
grant select on all tables in schema pg_toast to read_only;

也可以单独给某个表的查询权限
grant select on table tablename to read_only;
访问huanyu_fi数据库的schema
如果要在别的数据库
PG数据库如何新建只读用户
一 新建全局只读账号以超级用户登录数据库,创建用户。create user test password 'test' superuser;设置为只读transactiona...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇



