DROP OWNED

An SQL command for dropping objects owned by a role

DROP OWNED is a DDL for removing database objects owned by a particular role.

DROP OWNED was added in PostgreSQL 8.2.

Change history

Examples

Basic usage example for DROP OWNED:

postgres=# DROP OWNED BY bar;
DROP OWNED

If any dependencies such as foreign key relationships are present, the CASCADE keyword must be provided:

postgres=# DROP OWNED BY baz;
ERROR:  cannot drop table foo because other objects depend on it
DETAIL:  constraint bar_foo_id_fkey on table bar depends on table foo
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

Providing the name of a non-existent role:

postgres=# DROP OWNED BY baz;
ERROR:  role "baz" does not exist

Categories

DDL, SQL command, Users and roles

See also

REASSIGN OWNED