ALTER MATERIALIZED VIEW

Use ALTER MATERIALIZED VIEW to:

  • Rename a materialized view.
  • Change owner of a materialized view.
  • Change retain history configuration for the materialized view.

Syntax

Rename

To rename a materialized view:

ALTER MATERIALIZED VIEW <name> RENAME TO <new_name>;
Syntax element Description
<name> The current name of the materialized view you want to alter.
<new_name> The new name of the materialized view.

See also Renaming restrictions.

Change owner

To change the owner of a materialized view:

ALTER MATERIALIZED VIEW <name> OWNER TO <new_owner_role>;
Syntax element Description
<name> The name of the materialized view you want to change ownership of.
<new_owner_role> The new owner of the materialized view.

To change the owner of a materialized view, you must be the owner of the materialized view and have membership in the <new_owner_role>. See also Privileges.

(Re)Set retain history config

To set the retention history for a materialized view:

ALTER MATERIALIZED VIEW <name> SET (RETAIN HISTORY [=] FOR <retention_period>);
Syntax element Description
<name> The name of the materialized view you want to alter.
<retention_period> Private preview. This option has known performance or stability issues and is under active development. Duration for which Materialize retains historical data, which is useful to implement durable subscriptions. Accepts positive interval values (e.g. ‘1hr’). Default: 1s.

To reset the retention history to the default for a materialized view:

ALTER MATERIALIZED VIEW <name> RESET (RETAIN HISTORY);
Syntax element Description
<name> The name of the materialized view you want to alter.

Details

Privileges

The privileges required to execute this statement are:

  • Ownership of the materialized view.
  • In addition, to change owners:
    • Role membership in new_owner.
    • CREATE privileges on the containing schema if the materialized view is namespaced by a schema.
Back to top ↑