Skip to main content

DROP MATERIALIZED VIEW

Description

This statement is used to drop a materialized view.

Privilege requirements

To drop a materialized view log, you must have the DROP TABLE privilege. For more information about seekdb privileges, see seekdb privilege types.

Syntax

DROP MATERIALIZED VIEW [IF EXISTS] materialized_view_list [opt_drop_behavior];

materialized_view_list:
[ database. ]materialized_view [,[ database. ]materialized_view]...

opt_drop_behavior:
RESTRICT | CASCADE

Parameters

ParameterDescription
IF EXISTSOptional. If you specify IF EXISTS, the statement will not throw an error if the materialized view does not exist. If you do not specify this option, an error will be thrown if the materialized view does not exist.
database.Optional. Specifies the database where the materialized view is located. If you omit database., the materialized view will be dropped in your default database.
materialized_viewThe name of the materialized view.
RESTRICT | CASCADEOptional. Specifies the behavior of the drop operation.
  • CASCADE is the default value. It means that when you drop a materialized view, all dependent objects are also dropped.
  • RESTRICT means that if there are other objects dependent on the materialized view, the drop operation is not allowed.

Examples

Drop the materialized view named mv_test_tbl1 in the test_db database.

DROP MATERIALIZED VIEW mv_test_tbl1;

The return result is as follows:

Query OK, 0 rows affected (0.001 sec)

References