2.2上传(6个)源文件到该hive表的HDFS路径下
![](https://img-blog.csdnimg.cn/direct/c0eb55c8031846318238ae7d094d863f.png)
##### 3.查询数据
select * from t_all_hero;
![](https://img-blog.csdnimg.cn/direct/9211abf933aa4a01881d8b1708b554e6.png)
3.1查询出所有的archer数据
select * from t_all_hero where role_main=‘archer’;
问:虽然我们实现了需求, 但是需要进行全表扫描, 如何精准的获取到我们想要的数据呢?
答:可以采用分区表的思路来管理, 把各个职业的数据放到不同的文件夹中即可
##### 4.创建分区数据表
– 1. 创建分区表, 指定分区字段.
create table t_all_hero_part(
id int comment ‘ID’,
name string comment ‘英雄’,
hp_max int comment ‘最大生命’,
mp_max int comment ‘最大法力’,
attack_max int comment ‘最高物攻’,
defense_max int comment ‘最大物防’,
attack_range string comment ‘攻击范围’,
role_main string comment ‘主要定位’,
role_assist string comment ‘次要定位’
) comment ‘角色表’
partitioned by (role string comment ‘角色字段-充当分区字段’) – 核心细节: 分区字段必须是表中没有的字段.
row format delimited fields terminated by ‘\t’;
注意:分区字段必须是新的字段,表中没有的字段哦
##### 5.添加数据
###### 5.1添加方式1:静态分区(需要指定分区字段和值)
lo