DROP MATERIALIZED VIEW - Amazon Redshift

DROP MATERIALIZED VIEW

Removes a materialized view.

For more information about materialized views, see Materialized views in Amazon Redshift.

Syntax

DROP MATERIALIZED VIEW [ IF EXISTS ] mv_name [ CASCADE | RESTRICT ]

Parameters

IF EXISTS

A clause that specifies to check if the named materialized view exists. If the materialized view doesn't exist, then the DROP MATERIALIZED VIEW command returns an error message. This clause is useful when scripting, to keep the script from failing if you drop a nonexistent materialized view.

mv_name

The name of the materialized view to be dropped.

CASCADE

A clause that indicates to automatically drop objects that the materialized view depends on, such as other views.

RESTRICT

A clause that indicates to not drop the materialized view if any objects depend on it. This is the default.

Usage Notes

Only the owner of a materialized view can use DROP MATERIALIZED VIEW on that view. A superuser or a user who has specifically been granted DROP privileges can be exceptions to this.

When you write a drop statement for a materialized view and a view with a matching name exists, it results in an error that instructs you to use DROP VIEW. An error occurs even in a case where you use DROP MATERIALIZED VIEW IF EXISTS.

Example

The following example drops the tickets_mv materialized view.

DROP MATERIALIZED VIEW tickets_mv;