DROP MATERIALIZED VIEW

A DDL command for removing a materialized view

DROP MATERIALIZED VIEW is a DDL command for removing a materialized view.

DROP MATERIALIZED VIEW was added in PostgreSQL 9.3.

Change history

DROP MATERIALIZED VIEW has not changed since it was added in PostgreSQL 9.3.

Examples

Basic usage example for DROP MATERIALIZED VIEW:

postgres=# DROP MATERIALIZED VIEW bar;
DROP MATERIALIZED VIEW

Attempting to remove a materialized view with dependencies:

postgres=# DROP MATERIALIZED VIEW bar;
ERROR:  cannot drop materialized view bar because other objects depend on it
DETAIL:  materialized view bar2 depends on materialized view bar
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

Attempting to remove a non-existent materialized view:

postgres=# DROP MATERIALIZED VIEW boo;
ERROR:  materialized view "boo" does not exist

Attempting to execute DROP MATERIALIZED VIEW on an object which is not a materialized view:

postgres=# DROP MATERIALIZED VIEW foo;
ERROR:  "foo" is not a materialized view
HINT:  Use DROP TABLE to remove a table.

Categories

DDL, SQL command

See also

CREATE MATERIALIZED VIEW, ALTER MATERIALIZED VIEW