zoukankan      html  css  js  c++  java
  • hive(2)数据类型和文件格式

    基本的数据类型

    Hive支持关系型数据中大多数基本的数据类型,同时也支持关系型数据库中很少出现的三种集合数据类型。

    集合数据类型

    Hive中的列支持使用struct、map、array集合数据类型,下表中的语法示例是调用的内置函数。

    例如:创建表:

    hive>create table emp(name string, salary float, subordinates array<string>, deductions map<string,float>, address struct<stree:string, city:string, state:string, zip:int>);

    文本文件数据编码

    下图表示Hive中默认的记录和字段分隔符

    例如:创建表的时候,指定分隔符(示例中的分隔符都是默认的分隔符,如果想要指定其他的分隔符,可以重新设置。)

    hive> create table emp(name string, salary float, subordinates array<string>, deductions map<string,float>, address struct<stree:string, city:string, state:string, zip:int>)
    row format delimited
       fields terminated by '01'
    collection items terminated by '02'
    map keys terminated by '03'
    lines terminated by ' '
    stored as textfile;



    说明:

    row format delimited(行格式化分隔符)关键字需要在其他字句(除stored as...)之前
    fields terminated by:字段终止,指定字段的分隔符
    collection items terminated by:集合元素间的分隔符
    map keys terminated by:map键值之间的分隔符
    lines terminated by:指定行分隔符
    lines terminated by和stored as 不需要row format delimited关键字。
  • 相关阅读:
    非常好用的JS滚动代码
    在vs中使用ZedGraph
    通用SQL分页过程
    使用 Request.QueryString 接受参数时,跟编码有关的一些问题
    一个验证Email 的Javascript 函数
    DOS 下将文件名列表写入文件
    .NET 开发人员应该下载的十个必备工具
    中文全文搜索(一)
    关于<![if IE]>
    Lucene 全文索引心得
  • 原文地址:https://www.cnblogs.com/yjt1993/p/11059286.html
Copyright © 2011-2022 走看看