码迷,mamicode.com
首页 > 其他好文 > 详细

HIVE入门

时间:2016-08-21 00:47:50      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

HIVE入门
    $show databases;
        执行后发现默认有一个库default
    $show tables;
        发现没有任何表,证明不use其他库时,默认就是default库。
    $create database tedu;
        发现在hdfs中多出了/user/hive/warehouse/tedu.db目录
        结论1:hive中的数据库对应hdfs中/user/hive/warehouse目录下以.db结尾的目录。
    $use tedu;
    $create table student (id int,name string);
    $show tables;
    $desc student;
    $show create table student;
        发现正确创建出来了表。
        发现在hdfs中多出了/user/hive/warehouse/tedu.db/sutdent目录
        结论2:hive中的表对应hdfs/user/hive/warehouse/[db目录]中的一个目录
    $load data local inpath ‘../mydata/student.txt‘ into table student;
        发现/user/hive/warehouse/tedu.db/sutdent下多出了文件
    $select * from student;
        发现查出的数据不正确,原因是建表时没有指定分隔符。默认的分隔符是空格。
    $create table student2 (id int,name string) row format delimited fields terminated by ‘\t‘;
    $load data local inpath ‘../mydata/student.txt‘ into table student2;
    $select * from student2;
        发现正确查询出了数据。
        结论3:hive中的数据对应当前hive表对应的hdfs目录中的文件。
    $select count(*) from student;
        发现执行了mapreduce作业,最终现实了结果
        结论4:hive会将命令转换为mapreduce执行。
    $use default;
    $create table teacher(id int,name string);
        发现在hive对应的目录下多出了 tedu.db 文件夹,其中包含user文件夹。
        结论5:hive默认的default数据库直接对应/user/hive/warehouse目录,在default库中创建的表直接会在该目录下创建对应目录。

HIVE入门

标签:

原文地址:http://www.cnblogs.com/zpb2016/p/5791614.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!