PostgreSQL Database Groups

It is frequently convenient to group users together to ease management of privileges: that way, privileges can be granted to, or revoked from, a group as a whole. In PostgreSQL this is done by creating a role that represents the group, and then granting membership in the group role to individual user roles. CREATE GROUP is now an alias for CREATE ROLE.

Syntax:

CREATE GROUP name [ [ WITH ] option [ … ] ]
where option can be:
SUPERUSER | NOSUPERUSER
| CREATEDB | NOCREATEDB
| CREATEROLE | NOCREATEROLE
| CREATEUSER | NOCREATEUSER
| INHERIT | NOINHERIT
| LOGIN | NOLOGIN
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD ’password’
| VALID UNTIL ’timestamp’
| IN ROLE role_name [, …]
| IN GROUP role_name [, …]
| ROLE role_name [, …]
| ADMIN role_name [, …]
| USER role_name [, …]
| SYSID uid

How to add group to role and revoke group from role

GRANT group_role TO role1, … ;
REVOKE group_role FROM role1, … ;

Powered by k2schools