ALTER_GROUP(7pg18)
π ALTER GROUP π
okay so bestie, welcome to the ALTER GROUP page in the PostgreSQL 18.6 docs β yes, that PostgreSQL, and yes, that page number 7. this one's a lil retro, a lil vintage, a lil "we keep it around for the vibes and also for backwards compatibility" π«Ά
β¨ NAME β¨
ALTER_GROUP β change role name or membership π
πΈ SYNOPSIS πΈ
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. big important thing though: this command is obsolete, bestie π it's still accepted for backwards compatibility, but the reason it's obsolete is that groups (and users too, not just groups!) have been superseded by the more general concept of roles. so like. it works. it's just not the moment anymore.
the first two variants add users to a group or remove them from a group. and here's the cute part: any role can play the part of either a "user" or a "group" for this purpose π no gatekeeping.
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 GRANT or REVOKE, fr fr. and just so you know, GRANT and REVOKE have extra options that this command simply does not have, like:
- the ability to grant and revoke
ADMIN OPTION - the ability to specify the grantor
so like, ALTER GROUP is giving bare minimum and that's fine, but you deserve the full menu β¨
the third variant changes the name of the group. this is exactly equivalent to renaming the role with ALTER ROLE. same energy, different spelling π«
π PARAMETERS π
group_nameβ the name of the group (role) you're modifying. that's the one getting the glow-up.user_nameβ users (roles) that are to be added to or removed from the group. heads up: the users must already exist.ALTER GROUPdoes not create or drop users, it's not a babysitter, it's not a matchmaker, it just adds and removes πΈnew_nameβ the new name of the group. the rebrand π
β 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. not a single one. it's simply not there. so if you're out here expecting standard compliance, um, no π
π SEE ALSO π
GRANT(GRANT(7))REVOKE(REVOKE(7))ALTER ROLE(ALTER_ROLE(7))
and that's the page bestie π this was PostgreSQL 18.6, dated 2026, and the manual page is ALTER GROUP(7) β go forth and maybe just use GRANT and ALTER ROLE instead, iykyk πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms