postgresql用户与角色
- 作者: 书生李肆
- 来源: 51数据库
- 2020-09-30
用户是系统的使用者,而角色是指在企业管理中拥有某一类职能的组织,这个角色组织可以是实际的部门,可以是由拥有同一类职能的人构成的虚拟组织。
一个角色可以拥有多个用户,一个用户也可以分属于多个不同的角色 。
postgresql 设置只读用户
`
create user readonly with encrypted password 'ropass';
alter user readonly set default_transaction_read_only=on;
grant usage on schema public to readonly;
alter default privileges in schema public grant select on tables to readonly;
-- repeat code below for each database:
grant connect on database foo to readonly;
\c foo
grant usage on schema public to readonly;
grant select on all sequences in schema public to readonly;
grant select on all tables in schema public to readonly;
`
一个角色可以拥有多个用户,一个用户也可以分属于多个不同的角色 。
postgresql 设置只读用户
`
create user readonly with encrypted password 'ropass';
alter user readonly set default_transaction_read_only=on;
grant usage on schema public to readonly;
alter default privileges in schema public grant select on tables to readonly;
-- repeat code below for each database:
grant connect on database foo to readonly;
\c foo
grant usage on schema public to readonly;
grant select on all sequences in schema public to readonly;
grant select on all tables in schema public to readonly;
`
推荐阅读
