赞
踩
每次博客尽量以一个项目的标准来写,做到大家可以动手操作实践。
首先准备数据源:学生成绩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'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。