赞
踩
scores int,
city_code string,
cur_day string)
row format delimited fields terminated by ‘,’;
### 静态分区插入数据
* insert into,在city\_code=‘200’,cur\_day='20231111’分区下追加数据。
insert into table test_1
partition(city_code=‘200’,cur_day=‘20231111’)
select
t.id,
t.name,
t.classes,
t.scores
from test_1_tmp t where city_code=‘200’
;
* insert overwrite,删除在city\_code=‘200’,cur\_day='20231111’分区下数据,重新写入数据。
insert overwrite table test_1
partition(city_code=‘200’,cur_day=‘20231111’)
select
t.id,
t.name,
t.classes,
t.scores
from test_1_tmp t where city_code=‘200’
;
### 动态分区插入数据
* insert into / insert overwrite
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table test_1
partition(city_code,cur_day)
select
t.id,
t.name,
t.classes,
t.scores,
t.city_code,
t.cur_day
from test_1_tmp t
;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table test_1
p
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。