-- 创建角色:
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