1 hive建表語句
create table table_name
(id string, name stirng, score double)
partitioned by (dt string)
STORED AS PARQUET TBLPROPERTIES('parquet.compression'='gzip');
2 hive導入資料
2.1 普通查詢導入
insert into table my_table partition(dt='20210618')
select id,name,score from other_table where date_str='20210618'
2.2 hive導入資料-動态分區導入
-- 打開一些開關:動态分區開,非嚴格模式,動态分區數上限
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
SET hive.exec.max.dynamic.partitions=100000;
SET hive.exec.max.dynamic.partitions.pernode=100000;
insert into table my_table partition(dt)
select id,name,score,dt from other_table where dt>='20210601'
3 hive删減分區
ALTER TABLE table_Name DROP PARTITION (dt='20210618');