当前位置:   article > 正文

向hive中加载或添加数据的三种方式_hive insert into

hive insert into

 

每次博客尽量以一个项目的标准来写,做到大家可以动手操作实践。

首先准备数据源:学生成绩txt文件,共七个字段(ID,name,Chinese,English,math,school,class)

[root@xxx tmp]#  hdfs dfs -cat  /tmp/score.txt 
0001,zhangsan,99,98,100,school1,class1
0002,lisi,59,89,79,school2,class1
0003,wangwu,89,99,100,school3,class1
0004,zhangsan2,99,98,100,school1,class1
0005,lisi2,59,89,79,school2,class1
0006,wangwu2,89,99,100,school3,class1

 

建普通表:
create table score1
(id string comment 'ID', 
name string comment 'name',  
Chinese double comment 'Chinese',
English double comment 'English',
math double comment 'math',
school string comment 'school',
class string comment 'class')
comment 'score1'  
row format delimited fields terminated by ','
stored as textfile;

 

建分区表语句:

create table score
(id string comment 'ID', 
name string comment 'name',  
Chinese double comment 'Chinese',
English double comment 'English',
math double comment 'math')
comment 'score'  
partitioned by(school string,class string)
row format delimited fields terminated by ','

stored as textfile;

 

一、load加载

LOAD DATA [LOCAL] INPATH 'filepath'

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/853131
推荐阅读
相关标签
  

闽ICP备14008679号