zoukankan      html  css  js  c++  java
  • Hive的数据类型

    hive的基本数据类型

      1.基本数据类型

      hive类型        说明         java类型      实例
      1).tinyint      1byte有符号的整数    byte        20
      2).smalint      2byte有符号的整数     short         20
      3).int        4byte有符号的整数   int        20
      4).bigint      8byte有符号的整数   long       20
      5).boolean     布尔类型true或false    boolean     true
      6).float       单精度         float                  3.217
      7).double    双精度         double               3.212
      8).string      字符序列,单双即可   string           ‘zhang’;“ashakjds”
      9).timestamp    时间戳,精确的纳秒   timestamp        ‘158030219111’
      10).binary      字节数组        byte[]
      2.集合数据类型
        hive类型      说明                       java类型             实例
      1).struct        对象类型,可以通过字段名.元素名来访问      object          struct('name','age')
      2).map        一组键值对的元组                 map            map('name','zhangsan','age','23')
      3).array          数组                     array            array('name','age')
      4).union          组合
      3.案例:
        hive>create table employees(
          > name string,
          > salary float,
          > subordinates array<string>,
          > deductions map<string,float>,
          > address struct<street:string,city:string,state:string,zip:int>
          > );

    hive的数据编码格式

      1.默认hive通过^A(01)、^B(02)、^C(03)分别对列、(array和struct)、map进行匹配;

      2.创建表时,可以通过以下命令进行设置:
        row format delimited
        fields terminated by '01'
        collection items terminated by '02'
        map keys terminated by '03'
        lines terminated by ' '
      3.加载数据
        $>cd ~
        $>cp /mnt/hgfs/2.安装环境/data/employees/employees.txt .
        hive> load data local inpath '/home/hyxy/employees.txt' into table employees;
        hive>select * from employees;

    hive的读时模式

      1.传统的关系型数据库在进行数据加载时,必须验证数据格式是否符合表字段定义,如果不符合,数据将无法插入至数据库表中。这种模式称为“写时模式”。

      2.hive中,数据加载过程采用“读时模式”。

    hive数据存在什么地方

      1.数据将存储在hdfs中,在{/user/hive/warehouse/}目录的*_db下面。

      删除表中的全部数据,你将执行$>hadoop fs -rm /user/hive/warehouse/employees/employees.txt

      

     

  • 相关阅读:
    第二次作业
    初学JAVA的 感想 尹鑫磊
    初学JAVA 感想
    《将博客搬至CSDN》
    JAVA中的几种内部类
    JAVA-静态变量与实体变量
    teacher页面的代码
    测试说明书的概述和摘要
    网站的概述
    html与xhtml的区别
  • 原文地址:https://www.cnblogs.com/lyr999736/p/9468469.html
Copyright © 2011-2022 走看看