从
the PostgreSQL docs:
@H_301_2@The concept of roles subsumes the concepts of “users” and “groups”. In@H_301_2@为什么他们在8.1中做出这个改变? @H_301_2@也许从C编程者的角度来看,使用单个Role类(struct)更容易? @H_301_2@More details: @H_301_2@CREATE USER等同于CREATE ROLE,除了CREATE USER给用户/角色的LOGIN权限。 @H_301_2@(我即将为我的webapp设计权限系统,因此我对此感兴趣。)
Postgresql versions before 8.1,users and groups were distinct kinds
of entities,but now there are only roles. Any role can act as a user,
a group,or both.
合并有很多优点,没有缺点。例如,您现在可以通过添加/删除LOGIN权限将“用户”无缝转换为“组”,反之亦然。
ALTER ROLE myrole LOGIN; ALTER ROLE myrole NOLOGIN;@H_301_2@或者您可以将任何其他登录(“用户”)或非登录角色(“组”)的GRANT成员资格添加到角色:
GRANT joe TO sue;@H_301_2@你还可以:
CREATE USER james;@H_301_2@这只是role with login privilege。要么:
CREATE GROUP workers;@H_301_2@现在这是the same as
CREATE ROLE
。
@H_301_2@manual拥有这一切。