Skip to main content
ALTER TABLE ... MODIFY REFRESH replaces the whole REFRESH clause of a refreshable materialized view, and the refresh mode is part of that clause. If the view was created with APPEND and the new clause does not repeat it, ClickHouse treats the statement as an attempt to remove APPEND, which is not supported:
To change the schedule, repeat APPEND at the end of the new REFRESH clause. To change the mode itself, recreate the view with CREATE OR REPLACE MATERIALIZED VIEW.

Reproduce the error

The failed statement changes nothing: the view keeps its schedule. The opposite direction fails with the same message: you cannot add APPEND to a view that was created without it. The reference describes this limitation as “adding or removing APPEND is not supported”.

Repeat the mode in the new clause

The same rule applies to everything else in the clause, because the statement replaces all of it:
  • A view created with APPEND INCREMENTAL needs both keywords. APPEND alone is rejected with the same message.
  • The mode comes last, after RANDOMIZE FOR, DEPENDS ON and SETTINGS, as in MODIFY REFRESH EVERY 3 HOUR RANDOMIZE FOR 10 MINUTE SETTINGS refresh_retries = 5 APPEND. If you write SETTINGS after APPEND, the refresh settings are read as query settings and the statement fails with Unknown setting 'refresh_retries'. (UNKNOWN_SETTING).
  • A view created with SETTINGS all_replicas = 1 has to repeat that setting. Otherwise the statement fails with Altering setting 'all_replicas' is not supported. (NOT_IMPLEMENTED).
  • RANDOMIZE FOR, DEPENDS ON and the other refresh settings that you leave out are removed or reset to their defaults without an error.
system.view_refreshes has no column for the refresh mode. Use SHOW CREATE TABLE to see the current REFRESH clause of a view before you modify it.

Switch between the modes

A view cannot change its mode in place. Replace its definition with CREATE OR REPLACE MATERIALIZED VIEW. When the view writes to a table named in the TO clause, the statement replaces the view only, and the target table keeps its rows. What happens to these rows afterwards depends on the new mode. A view without APPEND replaces the whole content of its target table on every refresh, including rows that the view did not write:
The first refresh starts as soon as the view is created, and it replaced the rows appended earlier and the row inserted by hand. In the other direction, a view with APPEND adds the full result of its SELECT on every refresh, so rows are duplicated unless the SELECT only returns new rows. Add EMPTY to the CREATE OR REPLACE statement to skip the immediate first refresh. A view without a TO clause stores its rows in an inner table, and CREATE OR REPLACE drops that table together with the old view.