Version: 7.0.0

DROP MATERIALIZED VIEW ​

Function ​

DROP MATERIALIZED VIEW forcibly deletes an existing materialized view from the database.

Precautions ​

The owner of the materialized view, owner of the schema of the materialized view, and a user who has the DROP ANY TABLE permission can run the DROP MATERIALIZED VIEW command. By default, the system administrator can run this command.

Syntax ​

DROP MATERIALIZED VIEW [ IF EXISTS ] mv_name [, ...] [ CASCADE | RESTRICT ];

Parameter Description ​

  • IF EXISTS

    Reports a notice instead of an error if the specified materialized view does not exist.

  • mv_name

    Name of the materialized view to be deleted.

  • CASCADE | RESTRICT

    • CASCADE: automatically deletes the objects that depend on the materialized view.
    • RESTRICT: refuses to delete the materialized view if any objects depend on it. This is the default action.

Examples ​

-- Delete the materialized view named my_mv.
openGauss=# DROP MATERIALIZED VIEW my_mv;

ALTER MATERIALIZED VIEW, CREATE INCREMENTAL MATERIALIZED VIEW, CREATE MATERIALIZED VIEW, CREATE TABLE, REFRESH INCREMENTAL MATERIALIZED VIEW, and REFRESH MATERIALIZED VIEW