PostgreSQL创建只读用户权限


-- 创建角色:
create role read_only;
comment on role read_only is '只读角色【继承】';

-- 不能创建表,不能修改数据,添加数据
alter role read_only set default_transaction_read_only=on;


-- 给角色授权访问数据库:
grant connect on database   alcohol    to  read_only;
grant connect on database   bigdata    to  read_only;
grant connect on database   message  to  read_only;
-- 或者:
alter role read_only in database alcohol set default_transaction_read_only to true;
alter role read_only in database bigdata set default_transaction_read_only to true;
alter role read_only in database postgres set default_transaction_read_only to true;

-- 给角色授权访问数据库:
grant connect on database   alcohol  to  bp_lxj;
grant connect on database   message  to  bp_lxj;
grant connect on database   postgres to  bp_lxj;
-- 或者
alter role bp_lxj in database alcohol set default_transacti

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值