DROP_OWNED(7pg17)
πΈ NAME πΈ
hey bestie π welcome to the DROP OWNED page β aka DROP_OWNED(7), straight out of the PostgreSQL 17.11 docs. the actual NAME tea is: DROP_OWNED β remove database objects owned by a database role. periodt. π
β¨ SYNOPSIS β¨
DROP OWNED BY { name | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]
π DESCRIPTION π
okay so here's the vibe: DROP OWNED drops all the objects inside the current database that are owned by one of the roles you list. it also revokes any privileges granted to those roles on objects in the current database, plus on shared objects β that means databases, tablespaces, and configuration parameters. all of it. π
π PARAMETERS π
nameβ the name of a role whose objects will be dropped, and whose privileges will be revoked. that's the main character of this parameter list. πCASCADEβ automatically drops objects that depend on the affected objects, and in turn all objects that depend on those objects. it's giving domino effect. peep Section 5.15 for the full lore. π₯RESTRICTβ refuses to drop the objects owned by a role if any other database objects depend on one of the affected objects. this is the default, so if you don't pick anything, RESTRICT is what you get. no cap. π
π¦ NOTES π¦
DROP OWNED is often used to prepare for the removal of one or more roles. because it only affects the objects in the current database, it is usually necessary to execute this command in each database that contains objects owned by a role that is to be removed. yes, every single one β the way that database boundaries work is so real. π
β οΈ using the CASCADE option might make the command recurse to objects owned by other users. so like, be aware of that vibe check before you go full send. π
The REASSIGN OWNED command is an alternative that reassigns the ownership of all the database objects owned by one or more roles. but plot twist β REASSIGN OWNED does not deal with privileges for other objects. so they're not interchangeable, iykyk. π«Ά
Databases and tablespaces owned by the role(s) will not be removed. not me thinking this command nukes those too β it literally does not. π«
For more discussion, see Section 21.4. π
π COMPATIBILITY π
the DROP OWNED command is a PostgreSQL extension. that's the compatibility report, bestie β short, sweet, and iconic. β¨
π SEE ALSO π
REASSIGN OWNED(REASSIGN_OWNED(7))DROP ROLE(DROP_ROLE(7))
mwah π β this page comes from PostgreSQL 17.11, dated 2026, and itβs filed as DROP OWNED(7). now go slay your role cleanup, bestie π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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