赞
踩
lines terminated by ‘\n’;
2 ) 加载数据
user1.txt (user2.txt)
1 user1 1
2 user2 2
3 user1 1
4 user2 2
5 user2 2
6 user1 1
7 user2 1
8 user1 2
9 user2 2
load data local inpath ‘./root/user1.txt’ into table part1 partition(dt=‘2020-05-05’);
select * from part1;
1 user1 1 2020-05-05
2 user2 2 2020-05-05
3 user1 1 2020-05-05
4 user2 2 2020-05-05
5 user2 2 2020-05-05
6 user1 1 2020-05-05
7 user2 1 2020-05-05
8 user1 2 2020-05-05
9 user2 2 2020-05-05
load data local inpath ‘./root/user2.txt’ into table part1 partition(dt=‘2020-05-06’);
select * from part1 where dt=‘2020-05-05’;
1 ) 建表语句
create table if not exists part2(
id int,
name string,
age int
)
partitioned by (year string,month string)
row format delimited
fields terminated by ‘\t’;
2 ) 加载数据
load data local inpath ‘./root/user1.txt’ into table part1 partition(year=‘2020’,month=‘03’);
load data local inpath ‘./root/user1.txt’ into table part1 partition(year=‘2020’,month=‘04’);
load data local inpath ‘./root/user1.txt’ into table part1 partition(year=‘2020’,month=‘05’);
select * from part2 where year=‘2020’ and month=‘04’;
1 ) 建表语句
create table if not exists part2(
id int,
name string,
age int
)
partitioned by (year string,month string,day string)
row format delimited
fields terminated by ‘\t’;
2 ) 加载数据
load data local inpath ‘./root/user1.txt’ into table part1 partition(year=‘2020’,month=‘03’,day=‘01’);
load data local inpath ‘./root/user1.txt’ into table part1 partition(year=‘2020’,month=‘04’,day=‘02’);
load data local inpath ‘./root/user1.txt’ into table part1 partition(year=‘2020’,month=‘05’,day=‘03’);
select * from part2 where year='2020’and month='04’and day=‘02’;
在hive中,分区字段名是不区分大小写的,不过字段值是区分大小写的。
show partitions tableName;
show partitions part1
alter table part2 drop partition(year=‘2020’,month=‘05’,day=‘03’);
– 删除多个分区 逗号隔开
alter table part2 drop
partition(year=‘2020’,month=‘05’,day=‘03’),
partition year=‘2020’,month=‘04’,day=‘02’;
结论︰在删除操作时,对应的目录(最里层)会被删除,上级目录如果没有文件存在,也会被删除,如果有文件存在,则不会被删除。
1 )创建动态分区表
create table if not exists dy_part1(
id int,
name string,
gender string,
age int,
academy string
)
partitioned by (dt string)
row format delimited fields terminated by ‘\t’
;
2 )动态分区加载数据
下面方式不要用,因为不是动态加载数据
load data local inpath ‘./root/user1.txt’ into table dy_part1 partition(dt=‘2020-05-06’);
正确方式,要从别的表中加载数据
第一步:先创建临时表
create table if not exists temp_part1(
id int,
name string,
gender string,
age int,
academy string
)
partitioned by (dt string)
row format delimited fields terminated by ‘\t’
;
当然在这还有更多整理总结的Java进阶学习笔记和面试题未展示,其中囊括了Dubbo、Redis、Netty、zookeeper、Spring cloud、分布式、高并发等架构资料和完整的Java架构学习进阶导图!
更多Java架构进阶资料展示
[外链图片转存中…(img-5AfvQeCM-1714229176099)]
当然在这还有更多整理总结的Java进阶学习笔记和面试题未展示,其中囊括了Dubbo、Redis、Netty、zookeeper、Spring cloud、分布式、高并发等架构资料和完整的Java架构学习进阶导图!
[外链图片转存中…(img-viO7Iugb-1714229176100)]
更多Java架构进阶资料展示
[外链图片转存中…(img-i8byQI1Q-1714229176100)]
[外链图片转存中…(img-av8CCHu2-1714229176101)]
[外链图片转存中…(img-X3llynNv-1714229176101)]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。