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

     Hive之数据类型 

    第一节:原子数据类型

          9种

          整型4种 :tinyint、smallint、int、bigint

          浮点型:float 、double

          布尔:boolean

          字符串:string

          时间戳:timestamp

    第二节:复杂数据类型

    一、简介

          所有的复杂数据类型都是由原子数据类型构成

    二、array

    1、概念

          数组类型,一列中有多个数据组成,相同类型的。

    2、建表

    create table if not exists test_array(id int,work_add array<string>) row format delimited fields terminated by " " collection items terminated by ",";

        collection items terminated by 指定集合元素之间的分割符。指定分割符的顺序,一定是从外向内的指定,大->小。

    3、导入数据

          load data local inpath "/home/hadoop/tmpdata/test_array" into table test_array;

    三、map

    1、概念

      同java中的map 键值对类型的(map<string,int>)。

    2、建表

    create table if not exists test_map(id int,piaofang map<string,int>) row format delimited fields terminated by " " collection items terminated by "," map keys terminated by ":";

          collection items terminated by 指定的是整个map集合中,每一个元素之间的分割符的。

          map keys terminated by 指定map集合中 k-v之间的分割符的。

    3、导入数据

          load data local inpath "/home/hadoop/tmpdata/test_map" into table test_map;

    四、struct

    1、概念

    结构体,类似于java中的,实体类类型。

    2、建表

    id int    info struct<类似bean中的内容  属性名:类型,属性名:类型。。。。>

    create table if not exists test_struct(id int,info struct<name:string,age:int,sex:string,add:string>) row format delimited fields terminated by " " collection items terminated by ",";

    3、导入数据

          load data local inpath "/home/hadoop/tmpdata/test_struct" into table test_struct;

  • 相关阅读:
    python @ 修饰符
    收集一些NOSQL网站,以后有时间再来写NOSQL的一些心得
    网站性能问答
    CSLA筆記
    Google PR值原理和详细解说
    通天塔导游:各种编程语言优缺点
    网站访客行为和心理分析--决定网站的回头率
    pymongo 基本操作
    [摘]如何成为python高手
    用数组,列表或字典来代替选择语句
  • 原文地址:https://www.cnblogs.com/lizm166/p/13354952.html
Copyright © 2011-2022 走看看