DROP_OWNED(7pg13)

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

✨ NAME ✨

okay so bestie, welcome to DROP OWNED from the PostgreSQL 13.23 Documentation β€” manual page DROP_OWNED(7). It’s giving β€œremove database objects owned by a database role” energy. Periodt. πŸ’…


🌸 SYNOPSIS 🌸

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

πŸ¦‹ DESCRIPTION πŸ¦‹

So DROP OWNED literally drops all the objects within the current database that are owned by one of the specified roles. Bestie, it also revokes any privileges granted to the given roles on objects in the current database or on shared objects β€” that means databases and tablespaces. Iconic cleanup behavior, 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 the β€œand everything attached to it” option, lowkey powerful. πŸ”₯
  • 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. It’s the cautious queen of the two. πŸ‘‘

πŸ’… NOTES πŸ’…

  • DROP OWNED is often used to prepare for the removal of one or more roles. Main character prep era. πŸŽ€
  • 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. Like, every database. Don’t skip one, bestie. 😭
  • Using the CASCADE option might make the command recurse to objects owned by other users. So yes, it can wander into other people’s stuff β€” be aware. πŸ’€
  • The REASSIGN OWNED (REASSIGN_OWNED(7)) 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 vibe, different job. πŸ¦‹
  • Databases and tablespaces owned by the role(s) will not be removed. Ma’am stays. πŸ‘‘
  • See Section 21.4 for more discussion. ✨

🌈 COMPATIBILITY 🌈

The DROP OWNED command is a PostgreSQL extension. It’s special like that. πŸ’–


🫢 SEE ALSO 🫢

REASSIGN OWNED (REASSIGN_OWNED(7)), DROP ROLE (DROP_ROLE(7))


mwah πŸ’‹ β€” this was PostgreSQL 13.23, 2025, DROP OWNED(7). Go off, bestie. 🌟

πŸ“¦ where this page comes from