一、创建表
create table if not exists tmp(
date_stat_date datetime comment '统计日期_日期格式'
,platform string comment '端口'
,expose_uv bigint comment '曝光uv'
,avg_expose_pv double comment '人均曝光pv'
,avg_sign_times double comment '人均报名次数'
,income double comment '收入'
,benefit_ratio double comment '效益比'
,expose_jobs bigint comment '曝光岗位数'
,sign_jobs bigint comment '报名岗位数'
) partitioned by (ds string comment '分区');
二、导入数据
插入数据:
第一种写法(常用):
INSERT OVERWRITE TABLE tmp PARTITION(ds = '${bizdate}')
select * from xxxxx;
第二种写法:
INSERT OVERWRITE TABLE tmp PARTITION(ds)
select * ,ds from xxxxx;
三、批量删除分区数据
--批量删除分区数据
alter table tmp drop partition (ds<='20211231')
四、更新分区表生命周期
alter table table_name set lifecyle xxx;