v.21.1New Features
Allow CREATE TABLE AS SELECT with Column Specification
Allow create table as select with columns specification. Example CREATE TABLE t1 (x String) ENGINE = Memory AS SELECT 1;. #18060 (Maksim Kita).Why it matters
This feature enables users to define table schema explicitly while creating a table from a query, providing better control over column types and names. It solves the problem of implicitly inferred schema inCREATE TABLE AS SELECT, improving clarity and correctness of table definitions.How to use it
Use the syntaxCREATE TABLE table_name (column_name ColumnType) ENGINE = Engine AS SELECT ...; to create a table with specified columns and populate it from the query result. For example:CREATE TABLE t1 (x String) ENGINE = Memory AS SELECT 1;