zoukankan      html  css  js  c++  java
  • HIVE入门

    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 ' ';
        $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库中创建的表直接会在该目录下创建对应目录。

  • 相关阅读:
    自动化测试用例设计实例
    day07 python2与python3 编码
    day06-2 数据结构
    遇到一个关于C#调用Microsoft.Office.Interop.Word实例化的一个问题
    关于C#调用matlab生成的dll的一些经验(亲测)
    javascript 检测浏览类型和版本
    图片自适应完美兼容IE8
    Java VS .NET:Java与.NET的特点对比
    【C#点滴记录】ASP.NET 使用C# 导出Word 和Excel
    关于现在IT行业从业者一些建议
  • 原文地址:https://www.cnblogs.com/zpb2016/p/5791614.html
Copyright © 2011-2022 走看看