DROP_OWNED(7pg15)

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

πŸ’… 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 get RESTRICT πŸ₯°

πŸ”₯ 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 ⭐


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