Updated on 2024-04-28 GMT+08:00

ALTER MATERIALIZED VIEW

Function

Modifies the properties of a materialized view.

This syntax is supported only by clusters of 8.3.0 or later.

Precautions

None

Syntax

ALTER MATERIALIZED VIEW [ IF EXISTS ] { materialized_view_name }
    [ ENABLE | DISABLE ] QUERY REWRITE;
ALTER MATERIALIZED VIEW [ IF EXISTS ] { materialized_view_name }
    REFRESH [ COMPLETE ] [ ON DEMAND ] [ [ START WITH (timestamptz) ] | [ EVERY (interval) ] ];
ALTER MATERIALIZED VIEW { materialized_view_name }
    OWNER TO new_owner;

Parameter Description

  • ENABLE | DISABLE QUERY REWRITE

    Indicates whether to enable query rewriting for a materialized view.

    After enabling query rewriting for the materialized view, you need to refresh the materialized view to ensure that the data in the view is the latest.

  • REFRESH [ COMPLETE ] [ ON DEMAND ] [ [ START WITH (timestamptz) ] | [EVERY (interval)] ]

    Modifies the method of refreshing a materialized view.

  • OWNER TO new_owner

    Change the owner of a materialized view.

Examples

Enables query rewriting for a materialized view.

ALTER MATERIALIZED VIEW mv1 ENABLE QUERY REWRITE;
NOTICE:  REFRESH MATERIALIZED VIEW should be executed to enable query rewrite.
ALTER MATERIALIZED VIEW