v.22.7New Feature

Added CREATE TABLE ... EMPTY AS SELECT Query to Deduce Table Structure

Added CREATE TABLE ... EMPTY AS SELECT query. It automatically deduces table structure from the SELECT query, but does not fill the table after creation. Resolves #38049. #38272 (Alexander Tokmakov).
Introduced the CREATE TABLE ... EMPTY AS SELECT syntax to create new tables by automatically deriving the table structure from a specified SELECT query without populating the table with data.

Why it matters

This feature allows users to efficiently create tables with schemas inferred from existing queries, eliminating the need to manually define the table structure. It is useful when you want to prepare an empty table matching the result set of a SELECT query for later data insertion.

How to use it

Use the CREATE TABLE ... EMPTY AS SELECT syntax, where the table schema will be deduced from the SELECT query provided, but the table will be created empty without any data inserted.