ALTER_GROUP(7pg17)

πŸ“¦ version 17.11, in opensuse-leap 16.0

πŸ’… ALTER GROUP (7) β€” PostgreSQL 17.11 vibes

okay so bestie, welcome to ALTER GROUP from the PostgreSQL 17.11 Documentation. This is the page about changing a role's name or its membership, and yes it's giving "vintage command that still shows up to the party" energy, but we're gonna learn it properly. πŸŽ€


✨ SYNOPSIS ✨

ALTER GROUP role_specification ADD USER user_name [, ... ]
ALTER GROUP role_specification DROP USER user_name [, ... ]

where role_specification can be, and I quote:

    role_name
  | CURRENT_ROLE
  | CURRENT_USER
  | SESSION_USER
ALTER GROUP group_name RENAME TO new_name

like, three whole shapes of this command. pick your fighter. πŸ¦‹


🌸 DESCRIPTION 🌸

ALTER GROUP changes the attributes of a user group. Big heads-up though: this is an obsolete command β€” it's still accepted for backwards compatibility, but it's lowkey a legacy icon, because groups (and users too, fr fr) 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. (And honestly, any role can play the part of either a "user" or a "group" for this purpose β€” everybody's versatile like that. πŸ’…) 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. so yeah, GRANT/REVOKE ate and left no crumbs. πŸ”₯

The third variant changes the name of the group. This is exactly equivalent to renaming the role with ALTER ROLE.

bestie reminder: "obsolete" is not a vibe check fail, it's just a heads-up that the newer, shinier path exists. 😭

🧚 PARAMETERS 🧚

  • group_name β€” the name of the group (role) to modify. that's your main character right there.
  • user_name β€” users (roles) that are to be added to or removed from the group. and listen: the users must already exist; ALTER GROUP does not create or drop users. no inventing people, periodt.
  • new_name β€” the new name of the group. glow-up name, same role.

πŸ“ 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;

look at that. clean. iconic. no cap. ✨


🌈 COMPATIBILITY 🌈

There is no ALTER GROUP statement in the SQL standard. so it's a Postgres thing, not a committee thing. iykyk. πŸ™ˆ


🫢 SEE ALSO 🫢

  • GRANT(7)
  • REVOKE(7)
  • ALTER ROLE (ALTER_ROLE(7))

go read those too, they're the moment. πŸ’œ


PostgreSQL 17.11 Β· 2026 β€” and that's the whole page, bestie! page footer said PostgreSQL 17.11 and 2026, so shoutout to the version and the year. mwah, study well, slay your roles. πŸ‘‘πŸ’–πŸŽ€

πŸ“¦ where this page comes from