Skip to content

DROP OWNED BY

Drop all the objects in the current database that are owned by one more specified roles.

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

This command also revokes any privileges that were granted to the specified roles on objects in the current database.

For example:

premdb=# premdb=# drop owned by bobr;
DROP OWNED

In this example, user yb100 cannot be dropped until objects owned by yb100 are dropped.

premdb=# drop user yb100;
ERROR:  role "yb100" cannot be dropped because some objects depend on it
DETAIL:  owner of table bobr_match
owner of table bobr_team
owner of table bobr_season
premdb=# drop owned by yb100;
DROP OWNED
premdb=# drop user yb100;
DROP ROLE

You can use the CASCADE option to automatically drop objects that depend on the affected objects. RESTRICT is the default.

Note: Only the objects within a database can be dropped; role privileges, database-level privileges, and system-level privileges are ignored by this command.