日期
日期。存储为自 1970-01-01 以来的天数(无符号),占用两个字节。允许存储从 Unix 纪元开始后不久到编译阶段由常量定义的上限阈值(目前,这到 2149 年,但最终完全支持的年份是 2148 年)的值。
支持的值范围:[1970-01-01, 2149-06-06]。
日期值存储时不带时区。
示例
创建一个带有 Date
类型列的表并将数据插入其中
CREATE TABLE dt
(
`timestamp` Date,
`event_id` UInt8
)
ENGINE = TinyLog;
-- Parse Date
-- - from string,
-- - from 'small' integer interpreted as number of days since 1970-01-01, and
-- - from 'big' integer interpreted as number of seconds since 1970-01-01.
INSERT INTO dt VALUES ('2019-01-01', 1), (17897, 2), (1546300800, 3);
SELECT * FROM dt;
┌──timestamp─┬─event_id─┐
│ 2019-01-01 │ 1 │
│ 2019-01-01 │ 2 │
│ 2019-01-01 │ 3 │
└────────────┴──────────┘
另请参阅