标签:示例 ble 练习 for table external nbsp class 数据
1新建一个数据库
create database db3;
2创建一个外部表
--外部表建表语句示例: create external table student_ext(Sno int,Sname string,Sex string,Sage int,Sdept string) row format delimited fields terminated by ‘,‘ location ‘/stu‘;
3添加数据
vi student.txt
95001,李勇,男,20,CS 95002,刘晨,女,19,IS 95003,王敏,女,22,MA 95004,张立,男,19,IS 95005,刘刚,男,18,MA 95006,孙庆,男,23,CS 95007,易思玲,女,19,MA 95008,李娜,女,18,CS 95009,梦圆圆,女,18,MA 95010,孔小涛,男,19,CS 95011,包小柏,男,18,MA 95012,孙花,女,20,CS 95013,冯伟,男,21,CS 95014,王小丽,女,19,CS 95015,王君,男,18,MA 95016,钱国,男,21,MA 95017,王风娟,女,18,IS 95018,王一,女,19,IS 95019,邢小丽,女,19,IS 95020,赵钱,男,21,IS 95021,周二,男,17,MA 95022,郑明,男,20,MA
hdfs dfs -put student.txt /stu;
4 查询
select * from student_ext where Sno=95022;
5 group by分组
select sex,count(1) from student_ext group by sex;
6 cluster by 分区,排序
set mapred.reduce.tasks=4;
select * from student_ext cluster by sno;
create table tt_1 as select * from student_ext cluster by sno;
7
标签:示例 ble 练习 for table external nbsp class 数据
原文地址:https://www.cnblogs.com/feifeicui/p/10283695.html