how to set column default value like current_timestamp in clickhouse?

Viewed 6656

does anyone know how to use a default value like current_timestamp in mysql when creating a clickhouse table? The now() udf is dynamic, instead of the time the row inserted, it is always the current time, it changes when select.

Here is my table:

CREATE TABLE default.test2 (   
`num` UInt32,   
`dt` String,  
`__inserted_time` DateTime DEFAULT now()  
)  
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/test2', '{replica}')  
PARTITION BY dt  
ORDER BY dt  
SETTINGS index_granularity = 8192

I want the __inserted_time column value generated automatically thus I don't have to specify it in the insert into test2 (num,dt) values (1,'20191010')


my mistake, DEFAULT now() actually works

0 Answers
Related