Skip to main content

Overview

The REPLACE statement allows you to update a table atomically.
This statement is supported for the Atomic and Replicated database engines, which are the default database engines for ClickHouse and ClickHouse Cloud respectively.
Ordinarily, if you need to delete some data from a table, you can create a new table and fill it with a SELECT statement that does not retrieve unwanted data, then drop the old table and rename the new one. This approach is demonstrated in the example below:
Instead of the approach above, it is also possible to use REPLACE (given you are using the default database engines) to achieve the same result:

Syntax

All syntax forms for the CREATE statement also work for this statement. Invoking REPLACE for a non-existent table will cause an error.

Examples

Consider the following table:
We can use the REPLACE statement to clear all the data:
Or we can use the REPLACE statement to change the table structure:
Last modified on August 5, 2026