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;

  • 相关阅读:
    几个常见的在线评测系统,及我的点评
    信息学奥赛培训教材推荐
    致,青春
    文明小博客,管理员及网址列表
    NOIP2013,复赛及同步赛,报名及比赛,专题页面
    浅谈浏览器兼容性问题-(1)产生、看待与思考
    前端经典笔试题(腾讯前端,三栏布局)
    浅谈web语义化
    浅谈表现与数据分离
    浅谈w3c标准
  • 原文地址:https://www.cnblogs.com/lizm166/p/13354952.html
Copyright © 2011-2022 走看看