v.24.10Improvement

CREATE TABLE AS in ClickHouse Copies Key Clauses

CREATE TABLE AS will copy PRIMARY KEY, ORDER BY, and similar clauses (of MergeTree tables). #69739 (sakulali).
The CREATE TABLE AS statement in ClickHouse now copies PRIMARY KEY, ORDER BY, and similar clauses from existing MergeTree tables when creating a new table.

Why it matters

This feature simplifies table creation by preserving important table schema elements such as sorting and primary key definitions from an existing MergeTree table. It helps ensure consistency and reduces manual specification errors when duplicating table structures.

How to use it

To use this feature, run a CREATE TABLE new_table AS existing_table statement on a MergeTree table. The new table will automatically inherit the PRIMARY KEY, ORDER BY, and similar clauses from the source table.