ALTER GROUP
change role name or membership
English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- anchor
- SQL-ALTERGROUP
- file
- sql-altergroup.html
- lang
- en
- name
- ALTER GROUP
- purpose
- change role name or membership
- purpose zh
- 更改角色名称或成员资格
- sections same as
- Unknown
- slug
- 18
Syntax
ALTER GROUP role_specification ADD USER user_name [, ... ]
ALTER GROUP role_specification DROP USER user_name [, ... ]
where role_specification can be:
role_name
| CURRENT_ROLE
| CURRENT_USER
| SESSION_USER
ALTER GROUP group_name RENAME TO new_nameSyntax diagrams
Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.
ALTER GROUP · Syntax 2
role_specification
ALTER GROUP · Syntax 3
Definition PG 18
ALTER GROUP role_specification ADD USER user_name [, ... ] ALTER GROUP role_specification DROP USER user_name [, ... ] where role_specification can be: role_name | CURRENT_ROLE | CURRENT_USER | SESSION_USER ALTER GROUP group_name RENAME TO new_name
Description
ALTER GROUP changes the attributes of a user group. This is an obsolete command, though still accepted for backwards compatibility, because groups (and users too) have been superseded by the more general concept of roles.
The first two variants add users to a group or remove them from a group. (Any role can play the part of either a “user” or a “group” for this purpose.) These variants are effectively equivalent to granting or revoking membership in the role named as the “group”; so the preferred way to do this is to use GRANT or REVOKE. Note that GRANT and REVOKE have additional options which are not available with this command, such as the ability to grant and revoke ADMIN OPTION, and the ability to specify the grantor.
The third variant changes the name of the group. This is exactly equivalent to renaming the role with ALTER ROLE.
Parameters
group_nameThe name of the group (role) to modify.
user_nameUsers (roles) that are to be added to or removed from the group. The users must already exist;
ALTER GROUPdoes not create or drop users.new_nameThe new name of the group.
Examples
Add users to a group:
ALTER GROUP staff ADD USER karl, john;
Remove a user from a group:
ALTER GROUP workers DROP USER beth;
Compatibility
There is no ALTER GROUP statement in the SQL standard.
See Also
GRANT, REVOKE, ALTER ROLECompare versions
Complete source facts
synopsis html
ALTER GROUP <em class="replaceable"><code>role_specification</code></em> ADD USER <em class="replaceable"><code>user_name</code></em> [, ... ]
ALTER GROUP <em class="replaceable"><code>role_specification</code></em> DROP USER <em class="replaceable"><code>user_name</code></em> [, ... ]
<span class="phrase">where <em class="replaceable"><code>role_specification</code></em> can be:</span>
<em class="replaceable"><code>role_name</code></em>
| CURRENT_ROLE
| CURRENT_USER
| SESSION_USER
ALTER GROUP <em class="replaceable"><code>group_name</code></em> RENAME TO <em class="replaceable"><code>new_name</code></em>synopsis text
ALTER GROUP role_specification ADD USER user_name [, ... ] ALTER GROUP role_specification DROP USER user_name [, ... ] where role_specification can be: role_name | CURRENT_ROLE | CURRENT_USER | SESSION_USER ALTER GROUP group_name RENAME TO new_name
Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:f185fd730ab38be64b78eb86a6a50b5557e8cc791e0665dbd177f4e0a75cb553
Text language: en · wiki-repair-20261023:f185fd730ab38be64b78eb86a6a50b5557e8cc791e0665dbd177f4e0a75cb553