ALTER GROUP
The ALTER GROUP statement adds or removes a user account from a group.
Syntax
ALTER GROUP group-name
<ADD USER user-name [ , user-name ]...
| DROP USER user-name [ , user-name ]...>
Remarks
Only the Master user can execute this statement.
This statement must be used with one of the two available keywords.
A user account cannot be added to a group if the group is not already created in the database. To create users and add them to groups simultaneously, see
GRANT.
Dropping a user account from a group does not remove the group from the database.
User accounts cannot belong to multiple groups simultaneously. A user account cannot be added to a group if it is currently a member of another group. Such a user account must first be dropped from its current group and then added to another group.
A user name must be enclosed in double quotes if it contains spaces or other nonalphanumeric characters.
For further general information about users and groups, see
Master User and
Users and Groups in
Advanced Operations Guide, and
Assigning Permissions Tasks in
PSQL User's Guide.
Examples
The following examples show how to add a user account to a group:
ALTER GROUP developers ADD USER pgranger
The existing user account pgranger is added to the existing group developers.
============
ALTER GROUP developers ADD USER "polly granger"
The user account polly granger (containing nonalphanumeric characters) is added to the group developers.
============
ALTER GROUP developers ADD USER "polly granger", bflat
The user accounts polly granger (containing nonalphanumeric characters) and bflat are added to the group developers.
============
The following examples show how to drop a user account from a group.
ALTER GROUP developers DROP USER pgranger
The user account pgranger is removed from the group developers.
============
ALTER GROUP developers DROP USER "polly granger"
The user account polly granger (with a name containing nonalphanumeric characters) is removed from the group developers.
============
ALTER GROUP developers DROP USER "polly granger", bflat
The user accounts polly granger (containing nonalphanumeric characters) and bflat are removed from the group developers.
See Also