ALTER_GROUP(7pg13)

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

✨ ALTER GROUP πŸ’…

okay so bestie, welcome to the ALTER GROUP page from the PostgreSQL 13.23 Documentation β€” yes that's the manual name, don't @ me, I'm folding it in right at the top like a good hostess πŸŽ€

✨ NAME ✨

ALTER GROUP β€” change role name or membership. that's it. that's the whole vibe. lowkey iconic, highkey obsolete, we'll get there 🌸

✨ 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_USER
  | SESSION_USER
ALTER GROUP group_name RENAME TO new_name

✨ DESCRIPTION ✨

so ALTER GROUP changes the attributes of a user group. and here's the tea β˜• β€” this is an obsolete command, though it's still accepted for backwards compatibility, because groups (and users too, fr fr) have been superseded by the more general concept of roles. it's giving "your older cousin still using their MySpace" energy, but we respect her 🫢

the first two variants add users to a group or remove them from a group. and like, plot twist: 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(7) or REVOKE(7). periodt.

the third variant changes the name of the group. this is exactly equivalent to renaming the role with ALTER ROLE (ALTER_ROLE(7)). not similar, not kinda β€” exactly. no cap πŸ’…


✨ PARAMETERS ✨

  • group_name β€” the name of the group (role) to modify. like, the star of the show 🌟
  • user_name β€” users (roles) that are to be added to or removed from the group. and heads up bestie: the users must already exist; ALTER GROUP does not create or drop users. it's not a whole nursery, it just does membership 😭
  • new_name β€” the new name of the group. glow-up name, slay πŸ¦‹

✨ 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 karl and john getting into staff together β€” main character energy fr fr πŸŽ€ and beth? she's out of workers. it happens. we move πŸ’€

✨ COMPATIBILITY ✨

there is no ALTER GROUP statement in the SQL standard. none. zero. the standard said "not me" πŸ™ˆ so keep that in mind if you were about to @ the committee.

✨ SEE ALSO ✨

ngl bestie, if you're writing new code, go hang out with GRANT / REVOKE / ALTER ROLE instead β€” ALTER GROUP is here for the nostalgia, not the future ✨

and that's the whole page!! made it to the end, so proud of you πŸ₯Ή this little tour was brought to you by PostgreSQL 13.23, dated 2025, and the page is literally called ALTER GROUP(7) β€” see you in the next manpage, mwah πŸ’–πŸŒˆπŸ“

πŸ“¦ where this page comes from