DROP_OWNED(7pg15)
π DROP OWNED β the "bestie, pack your stuff" of PostgreSQL
okay so real talk, this page is DROP OWNED from the PostgreSQL 15.19 docs, manual page 7pg15. She's a little chaotic but honestly an icon once you get her vibe. Let's go π
β¨ NAME β¨
DROP_OWNED β remove database objects owned by a database role π§Ή
πΈ SYNOPSIS πΈ
DROP OWNED BY { name | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]
like yes, you can list several roles, comma-separated, and each one can be an actual name or one of the special keywords CURRENT_ROLE, CURRENT_USER, SESSION_USER π«Ά
π DESCRIPTION π
DROP OWNED drops, like, all the objects inside the current database that are owned by one of the roles you name. That's it, that's the whole plot π
but wait, there's more β any privileges that were granted to those roles on objects in the current database, or on shared objects (databases, tablespaces, configuration parameters), get revoked too. so it's drops and revokes. double duty, main character energy π
π¦ PARAMETERS π¦
nameβ the name of a role whose objects are gonna get dropped, and whose privileges are gonna get revoked. just say who πCASCADEβ automatically drops the objects that depend on the affected objects, and then in turn all the objects that depend on those objects (peep Section 5.14 for the full lore). it's giving domino effect πRESTRICTβ refuses to drop the objects owned by a role if any other database objects depend on one of the affected objects. this one is the default, so if you don't say anything, you getRESTRICTπ₯°
π₯ NOTES π₯
DROP OWNED is often used to prep for removing one or more roles. like, the cleanup-before-the-goodbye moment π
because DROP OWNED only affects objects in the current database, it's usually necessary to run this command in each database that contains objects owned by a role that's getting removed. yes, every single one. no skipping, bestie π
using the CASCADE option might make the command recurse into objects owned by other users. so like, be aware, that's a whole thing π
REASSIGN OWNED is the alternative β it reassigns ownership of all the database objects owned by one or more roles instead. cute! but plot twist: REASSIGN OWNED does not deal with privileges for other objects. different job, different girl π
also important: databases and tablespaces owned by the role(s) will not be removed. nope. they stay. π«Ά
see Section 22.4 for more discussion if you want the deep dive β
π COMPATIBILITY π
DROP OWNED is a PostgreSQL extension. so like, it's our thing β you won't find this exact vibe elsewhere π
β SEE ALSO β
REASSIGN OWNED(REASSIGN_OWNED(7))DROP ROLE(DROP_ROLE(7))
okay that's the whole page, you ate that π this was PostgreSQL 15.19, dated 2026, signing off β go forth and drop responsibly, ily, mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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