DROP OWNED is a DDL for removing database objects owned by a particular role.
DROP OWNED was added in PostgreSQL 8.2.
Basic usage example for
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