Back to Materialize

DROP MATERIALIZED VIEW

doc/user/content/sql/drop-materialized-view.md

1231.6 KB
Original Source

DROP MATERIALIZED VIEW removes a materialized view from Materialize. If there are other views depending on the materialized view, you must explicitly drop them first, or use the CASCADE option.

Syntax

mzsql
DROP MATERIALIZED VIEW [IF EXISTS] <view_name> [RESTRICT|CASCADE];
Syntax elementDescription
IF EXISTSOptional. If specified, do not return an error if the named materialized view does not exist.
<view_name>The materialized view you want to drop. For available materialized views, see SHOW MATERIALIZED VIEWS.
RESTRICTOptional. Do not drop this materialized view if any other views depend on it. (Default)
CASCADEOptional. If specified, drop the materialized view and all views that depend on this materialized view.

Examples

Dropping a materialized view with no dependencies

mzsql
DROP MATERIALIZED VIEW winning_bids;
nofmt
DROP MATERIALIZED VIEW

Dropping a materialized view with dependencies

mzsql
DROP MATERIALIZED VIEW winning_bids;
nofmt
ERROR:  cannot drop materialize.public.winning_bids: still depended
upon by catalog item 'materialize.public.wb_custom_art'

Privileges

The privileges required to execute this statement are:

{{% include-headless "/headless/sql-command-privileges/drop-materialized-view" %}}