SELECT query that was specified when a materialized view was created with the ALTER TABLE ... MODIFY QUERY statement without interrupting ingestion process.
This command is created to change materialized view created with TO [db.]name clause. It does not change the structure of the underlying storage table and it does not change the columns’ definition of the materialized view, because of this the application of this command is very limited for materialized views are created without TO [db.]name clause.
Example with TO table
SELECT section without adding new columns.
Required privileges
ALTER TABLE ... MODIFY QUERY requires the ALTER VIEW MODIFY QUERY privilege on the view. The new query runs with the SQL security of the view, so the statement also requires the grants that are necessary to create a view with that SQL security:
SQL SECURITY DEFINERwith a definer that is not the current user:SET DEFINERon that definer.SQL SECURITY NONE:ALLOW SQL SECURITY NONE.
MODIFY SQL SECURITY, these grants are required for the new SQL security instead of the old one.
With ON CLUSTER, the statement is authorized on the host where it runs, so that host must have the view. Otherwise the statement fails with UNKNOWN_TABLE.
ALTER TABLE … MODIFY REFRESH Statement
ALTER TABLE ... MODIFY REFRESH changes refresh parameters of a Refreshable Materialized View, including the schedule, dependencies, randomization, and refresh settings.
EVERY or AFTER) is mandatory: the statement replaces all refresh parameters at once. Any clause not specified — RANDOMIZE FOR, DEPENDS ON, or SETTINGS — is removed or reset to defaults. To change only refresh settings, repeat the current schedule.
The command updates the refresh configuration of the existing view in place without recreating the materialized view or its target table, clearing existing target data, or canceling an already-running refresh. Reads continue against the existing target table while the configuration is changed.
Repeating the command with the same complete REFRESH specification is safe. Make sure to repeat every clause that should remain configured, because each execution replaces all refresh parameters as described above.
ALTER TABLE ... MODIFY SETTINGis not supported on materialized views; refresh settings can only be changed viaMODIFY REFRESH.- Adding or removing
APPENDis not supported. - The
all_replicasrefresh setting cannot be changed after the view is created.
system.view_refreshes.