DROP_ROLE(7pg16)

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

✨ NAME ✨

DROP_ROLE β€” remove a database role. This is the DROP_ROLE(7) page from the PostgreSQL 16.15 Documentation, and yes bestie, we’re gonna get into it πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

DROP ROLE [ IF EXISTS ] name [, ...]

πŸ’… DESCRIPTION πŸ’…

okay so DROP ROLE removes the specified role(s) β€” like, poof, gone. But there are rules, because of course there are. To drop a superuser role, you must be a superuser yourself. To drop non-superuser roles, you must have CREATEROLE privilege and have been granted ADMIN OPTION on the role. no cap, that’s the vibe check πŸ”₯

A role cannot be removed if it is still referenced in any database of the cluster; an error will be raised if so 😭 Before dropping the role, you must drop all the objects it owns (or reassign their ownership) and revoke any privileges the role has been granted on other objects. The REASSIGN OWNED and DROP OWNED commands can be useful for this purpose; see Section 22.4 for more discussion. slay, but do the cleanup first 🧹✨

However, it is not necessary to remove role memberships involving the role; DROP ROLE automatically revokes any memberships of the target role in other roles, and of other roles in the target role. The other roles are not dropped nor otherwise affected. iconic behavior, honestly πŸ‘‘


🌸 PARAMETERS 🌸

  • IF EXISTS β€” Do not throw an error if the role does not exist. A notice is issued in this case. basically β€œif she’s not there, don’t make it weird” πŸ’…
  • name β€” The name of the role to remove. the actual role you’re yeeting 🫢

πŸ¦‹ NOTES πŸ¦‹

PostgreSQL includes a program dropuser(1) that has the same functionality as this command (in fact, it calls this command) but can be run from the command shell. so you can do the same thing from your terminal, iykyk πŸ’»βœ¨


🌈 EXAMPLES 🌈

To drop a role:

DROP ROLE jonathan;

periodt, jonathan is gone πŸ’€


⭐ COMPATIBILITY ⭐

The SQL standard defines DROP ROLE, but it allows only one role to be dropped at a time, and it specifies different privilege requirements than PostgreSQL uses. so yeah, not a total match β€” read the room πŸ“š


🫢 SEE ALSO 🫢


and that’s the tea 🍡 β€” this iconic page is from PostgreSQL 16.15, dated 2026, and it’s DROP ROLE(7) signing off πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from