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.
  • Apply a replacement materialized view. Public preview.

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.

Apply replacement

PREVIEW This feature is in public preview. It is under active development and may have stability or performance issues. It isn't subject to our backwards compatibility guarantees.

To apply a replacement materialized view:

ALTER MATERIALIZED VIEW <name> APPLY REPLACEMENT <replacement_name>;
Syntax element Description
<name> The name of the materialized view to replace.
<replacement_name> The name of a replacement materialized view created with CREATE REPLACEMENT MATERIALIZED VIEW.

This operation replaces the definition of the target materialized view with the definition of the replacement, and drops the replacement at the same time.

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.
  • In addition, to apply a replacement:
    • Ownership of the replacement materialized view.
Back to top ↑