DROP_OWNED(7pg14)

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

πŸŽ€ NAME πŸŽ€

This is the DROP_OWNED(7pg14) page from the PostgreSQL 14.24 docs, bestie β€” and the actual command is DROP OWNED. It removes database objects that are owned by a database role. Periodt. πŸ’…


⚑ SYNOPSIS ⚑

DROP OWNED BY { name | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]

πŸ’– DESCRIPTION πŸ’–

Okay so DROP OWNED drops all the objects within the current database that are owned by one of the specified roles. That β€œcurrent database” part is doing a lot of work, so don’t forget it. πŸ‘‘

Any privileges granted to the given roles on objects in the current database β€” or on shared objects (databases, tablespaces) β€” will also be revoked. Yes, both. No cap. ✨


🌸 PARAMETERS 🌸

  • name β€” the name of a role whose objects will be dropped, and whose privileges will be revoked. 🫢
  • CASCADE β€” automatically drop objects that depend on the affected objects, and in turn all objects that depend on those objects (see Section 5.14). It’s giving β€œcleanup with consequences,” lowkey. πŸ”₯
  • RESTRICT β€” refuse 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 it’s the chill safety-net vibe. πŸ›‘οΈ

πŸ¦‹ NOTES πŸ¦‹

  • DROP OWNED is often used to prepare for the removal of one or more roles. Like, it’s the pre-game before the role actually leaves the chat. πŸ‘‹
  • Because DROP OWNED 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, each one β€” iykyk. 😭
  • Using the CASCADE option might make the command recurse to objects owned by other users. Heads up, bestie β€” that’s a real caveat, not a vibe. πŸ’€
  • The REASSIGN OWNED command is an alternative that reassigns the ownership of all the database objects owned by one or more roles. However, REASSIGN OWNED does not deal with privileges for other objects. Different tool, different job. 🧚
  • Databases and tablespaces owned by the role(s) will not be removed. They stay. Iconic, honestly. πŸŽ€
  • See Section 22.4 for more discussion. πŸ“–

🌈 COMPATIBILITY 🌈

The DROP OWNED command is a PostgreSQL extension. It’s not some universal SQL standard moment β€” it’s very much a PostgreSQL thing. πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘


Source/version: PostgreSQL 14.24 Β· Date: 2026 Β· Page: DROP OWNED(7) β€” bye bestie, go drop your owned objects responsibly βœ¨πŸ’–πŸ«Ά

πŸ“¦ where this page comes from