0
点赞
收藏
分享

微信扫一扫

Hive加载数据的方式

独兜曲 2022-02-19 阅读 80

方式一
1. 在hdfs上新建一个目录:dfs -mkdir /user/hive/warehouse/pgdb.db/dept_partition/year=2018;

2. 上传文件:dfs -put /home/hduser/software/hive_1.2.1/hive_data/dept.txt /user/hive/warehouse/pgdb.db/dept_partition/year=2018;

	这个时候通过hive客户端查询不到数据
3. 执行修复命令: msck table dept_partition;

这个时候通过hive客户端就可以查询到数据了

方式二
1. 在hdfs上新建一个目录:dfs -mkdir /user/hive/warehouse/pgdb.db/dept_partition/year=2017;

2. 上传文件:dfs -put /home/hduser/software/hive_1.2.1/hive_data/dept.txt /user/hive/warehouse/pgdb.db/dept_partition/year=2017;


3. 添加分区表:alter table dept_partition add partition(year='2017'); 在查询结果有数据

方式三
1. 在hdfs上新建一个目录:dfs -mkdir /user/hive/warehouse/pgdb.db/dept_partition/year=2016;

2. load方式直接加载数据: load data local inpath '/home/hduser/software/hive_1.2.1/hive_data/dept.txt' into table dept_partition partition(year='2016');

查看数据

在这里插入图片描述

举报

相关推荐

0 条评论