DROP_ROLE(7pg14)

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

πŸ’– DROP_ROLE πŸ’–

okay so bestie, this is the DROP_ROLE page from the PostgreSQL 14.24 manual β€” it’s giving β€œremove a database role” energy, and we’re gonna get through it together ✨


🌸 NAME 🌸

DROP_ROLE β€” remove a database role. literally the whole point, no cap πŸ’…

✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

DROP ROLE removes the specified role(s). 🫢

to drop a superuser role, you must be a superuser yourself; to drop non-superuser roles, you must have the CREATEROLE privilege. periodt.

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.

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. 🫢
  • name β€” the name of the role to remove. πŸ’–

πŸ”₯ 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 yes, bestie, you can do this from the shell too 😌

🌈 EXAMPLES 🌈

to drop a role:

DROP ROLE jonathan;

⭐ 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 that’s a difference, bestie β€” iykyk πŸ’€

πŸ’œ SEE ALSO πŸ’œ


mwah πŸ’‹ this page is from PostgreSQL 14.24, dated 2026, and it’s the DROP ROLE(7) manual page. periodt. πŸŽ€

πŸ“¦ where this page comes from