hive学习之经典sql50题 hive版(一)

尽管hql与sql差不多,

但还是想把学生教师成绩sql版的改个hive版的,

一方面提升自己hql能力,一方面希望帮到广大准备入手hive的同学

有什么不足的地方,欢迎评论

建表:

create table student(sid string,sname string,sage int,ssex string) row format delimited fields terminated by '\t';

create table course(cid string,cname string,tid string) row format delimited fields terminated by '\t';

create table teacher(tid string,tname string) row format delimited fields terminated by '\t';

create table sc(sid string,cid string,score int) row format delimited fields terminated by '\t';

生成数据

vi /usr/local/etc/student

01      赵雷    19900101        男
02      钱电    19901221        男
03      孙风    19900520        男
04      李云    19900806        男
05      周梅    19911201        女
06      吴兰    19920301        女
07      郑竹    19890701        女

08      王菊    19900120        女


vi /usr/local/etc/course

01 语文 02
02 数学 01

03 英语 03


vi /usr/local/etc/teacher

01 张三
02 李四

03 王五


vi /usr/local/etc/sc

01 01 80
01 02 90
01 03 99
02 01 70
02 02 60
02 03 80
03 01 80
03 02 80
03 03 80
04 01 50
04 02 30
04 03 20
05 01 76
05 02 87
06 01 31
06 03 34
07 02 89

07 03 98

导数据到hive

load data local inpath '/usr/local/etc/student' into table student;

load data local inpath '/usr/local/etc/course' into table course;

load data local inpath '/usr/local/etc/teacher' into table teacher;

load data local inpath '/usr/local/etc/sc' into table sc;





猜你喜欢

转载自blog.csdn.net/zhaolq1024/article/details/80748694
今日推荐