Search code examples
clickhouse

how to do select into table with clickhouse?


I'm new to Clickhouse but I recall SQL having select into capabilities.

SELECT column1, column2, column3, ...
INTO newtable 
FROM oldtable
WHERE condition;

What is the Clickhouse way to do that ?


Solution

  • create table xxx_new Engine=Log as select 1 a, 2 b
    
    DESCRIBE TABLE xxx_new
    
    ┌─name─┬─type──┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
    │ a    │ UInt8 │              │                    │         │                  │                │
    │ b    │ UInt8 │              │                    │         │                  │                │
    └──────┴───────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘