Updated on 2024-09-03 GMT+08:00

ALTER MATERIALIZED VIEW

Function

Modifies the properties of a materialized view.

The materialized view feature is only supported by clusters 8.3.0 or later versions. If you want to use this feature, reach out to technical support for assistance.

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, refresh the materialized view to ensure the data is up-to-date.

  • 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.

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