DROP_OWNED(7pg13)
β¨ 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 OWNEDis often used to prepare for the removal of one or more roles. Main character prep era. π- Because
DROP OWNEDonly 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
CASCADEoption 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 OWNEDdoes 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
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-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