DROP_ROLE(7pg16)
β¨ 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 π«Ά
CREATE ROLE(CREATE_ROLE(7))ALTER ROLE(ALTER_ROLE(7))SET ROLE(SET_ROLE(7))
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
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms