DROP_OWNED(7pg14)
π 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 (seeSection 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 OWNEDis 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 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. Yes, each one β iykyk. π - Using the
CASCADEoption might make the command recurse to objects owned by other users. Heads up, bestie β thatβs a real caveat, not a vibe. π - The
REASSIGN OWNEDcommand 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 tool, different job. π§ - Databases and tablespaces owned by the role(s) will not be removed. They stay. Iconic, honestly. π
- See
Section 22.4for 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 π
REASSIGN OWNED(REASSIGN_OWNED(7))DROP ROLE(DROP_ROLE(7))
Source/version: PostgreSQL 14.24 Β· Date: 2026 Β· Page: DROP OWNED(7) β bye bestie, go drop your owned objects responsibly β¨ππ«Ά
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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