时间类型:DATETIME
范围:1000-01-01 00:00:00/9999-12-31 23:59:59
格式:YYYY-MM-DD HH:MM:SS
在插入的数据格式与datetime的数据格式有差别时,部分会自动调整,测试如下
--建表语句
create table test(
finish_date datetime
)
insert into test values('2020-06-09 09:57:00');
insert into test values('2020-6-9 10:00:00');
insert into test values('2020/03/04')
insert into test values('2020/3/4')
insert into test values('20200120');
insert into test values('2020');
insert into test values('202000');
insert into test values('202001');
insert into pccm.test values('202068');
在插入上述两条数据后,6-9会自动调整为06-09,查询结果如下:
select * from test;
finish_date
2020-06-09 09:57:00
2020-06-09 10:00:00
2020-03-04 00:00:00
2020-03-04 00:00:00
2020-01-20 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
注:
在能够分割出完整年月日的数据可以转化为正确的datetime格式,否则为默认的数据‘0000-00-00 00:00:00’
hive中的date类型同理,但是不识别没有年月日没有‘-’分割的数据,不符合格式的数据插入结果为NULL