Hive中HQL的数据类型

原子数据类型(9种)

  1. 整型:tinyint、smallint、int、bigint
  2. 浮点型:float、double
  3. 布尔:boolean
  4. 字符串:string
  5. 时间戳:timestamp

复杂数据类型

  • 简介
    • 所有的复杂数据类型都是由原子数据类型构成
  1. array
    • 概述
create table if not exists test_array(id int,work_add array<string>) 
row format delimited fields terminated by "\t" collection items terminated by ",";
--  collection items terminated by 指定集合元素之间的分割符。指定分割符的顺序,一定是从外向内的指定,大->小。
-建表
   load data local inpath "/home/hadoop/tmpdata/test_array" into table test_array;
- 导入数据
   load data local inpath "/home/hadoop/tmpdata/test_array" into table test_array;
  1. map
    • 概念
      同java中的map 键值对类型的(map<string,int>)。
    • 建表
create table if not exists test_map(id int,piaofang map<string,int>) row format delimited fields terminated by "\t" collection items terminated by "," map keys terminated by ":";
--  collection items terminated by 指定的是整个map集合中,每一个元素之间的分割符的。
--  map keys terminated by 指定map集合中 k-v之间的分割符的。
- 导入数据
load data local inpath "/home/hadoop/tmpdata/test_map" into table test_map;
  1. struct
    • 概述
      结构体,类似于java中的,实体类类型。
    • 建表
-- 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 "\t" collection items terminated by ",";
- 导入数据   
    load data local inpath "/home/hadoop/tmpdata/test_struct" into table test_struct;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

领头喵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值