Synopsis

Use the ALTER MATERIALIZED VIEW statement to change the definition of a materialized view.

Syntax

alter_materialized_view ::= ALTER MATERIALIZED VIEW [ IF EXISTS ] 
                            matview_name 
                            alter_materialized_view_action [ , ... ]

alter_materialized_view_action ::= RENAME TO new_name
                                   | SET TABLESPACE tablespace_name

alter_materialized_view

ALTERMATERIALIZEDVIEWIFEXISTSmatview_name,alter_materialized_view_action

alter_materialized_view_action

RENAMETOnew_nameSETTABLESPACEtablespace_name

Semantics

alter_materialized_view_action

Specify one of the following actions.

RENAME TO new_name

Rename the materialized view to the specified name.

Note

Renaming a materialized view is a non-blocking metadata change operation.

SET TABLESPACE tablespace_name

Asynchronously change the tablespace of an existing materialized view. The tablespace change will immediately reflect in the config of the materialized view, however the tablet move by the load balancer happens in the background. While the load balancer is performing the move it is perfectly safe from a correctness perspective to do reads and writes, however some query optimization that happens based on the data location may be off while data is being moved.

Example
yugabyte=# ALTER MATERIALIZED VIEW mv SET TABLESPACE mv_tblspace2;
yugabyte=# NOTICE:  Data movement for table mv is successfully initiated.
yugabyte=# DETAIL:  Data movement is a long running asynchronous process and can be monitored by checking the tablet placement in http://<YB-Master-host>:7000/tables

See also