v.24.9Improvement
CREATE TABLE AS now supports PRIMARY KEY and ORDER BY for MergeTree engines
CREATE TABLE AS now copies PRIMARY KEY, ORDER BY, and similar clauses. Now it supports only for MergeTree family of table engines. #69076 (sakulali).
Why it matters
This feature simplifies the process of duplicating tables by automatically carrying over key structural definitions such asPRIMARY KEY and ORDER BY clauses. It reduces manual effort and potential errors when creating similar tables based on existing table schemas, thereby improving developer productivity and consistency.How to use it
When usingCREATE TABLE AS with tables from the MergeTree family, the statement will automatically copy the original table's PRIMARY KEY, ORDER BY, and similar clauses. No additional parameters or flags are needed to enable this behavior.