v.21.1New Features

Implemented REPLACE TABLE and CREATE OR REPLACE TABLE Queries

Implemented REPLACE TABLE and CREATE OR REPLACE TABLE queries. #18521 (tavplubix).
Implemented REPLACE TABLE and CREATE OR REPLACE TABLE queries in ClickHouse.

Why it matters

This feature allows users to atomically replace an existing table with a new one or create the table if it does not exist, simplifying schema updates and table management without manual drop and create steps.

How to use it

Users can use the REPLACE TABLE statement to replace an existing table with a new table definition and data. Alternatively, CREATE OR REPLACE TABLE can be used to create a table or replace it if it already exists. For example:

CREATE OR REPLACE TABLE table_name (...);
REPLACE TABLE table_name AS SELECT * FROM another_table;