1.TO_CHAR:将日期类型date按照format指定的格式转成字符串。
SELECT TO_CHAR('2018-10-27 22:17:55','yyyymmddhhmiss') as stg_rksj FROM table1;
返回20181027221755
2.TO_DATE:将一个format格式的字符串date转成日期值,返回Datetime类型,格式为yyyy-mm-dd hh:mi:ss 。若任意一个输入的参数为NULL,则返回NULL值。
SELECT TO_DATE('20181027221755','yyyymmddhhmiss') as dw_rksj FROM table1 ;
返回2018-10-27 22:17:55
https://help.aliyun.com/document_detail/48974.html?spm=a2c4g.11186623.6.641.6908676cvVXK9X#h2-url-8
二.使用INSERT INTO插入数据
1.示例1,插入固定分区
INSERT INTO TABLE ods_vcs_rljghxx_test PARTITION (ds='20181220',hh='16',mm='00') (wzbjsj) VALUES (datetime'2018-12-20 17:36:59');
2.示例2,动态插入,即不明确分区,在插入时再确定
INSERT INTO TABLE ods_vcs_rljghxx_test PARTITION (ds,hh,mm) (wzbjsj,ds,hh,mm) VALUES (datetime'2018-12-20 18:16:59','20181220','17','00');
2.示例3,插入无分区表
INSERT INTO TABLE coordconvert VALUES
('31011813001321022057','121.2604623','31.18352674'),
('31011815001321021008','121.21535','31.228076');
三.删除分区
ALTER table table1 DROP PARTITION (dt='20181225');