hive的数据类型

基本数据类型

因为hive也是java编写的,所以它的基本数据类型和java大致相同
在这里插入图片描述

集合数据类型

hive中的列支持struct、map、array集合数据类型

array(数组)

特点:个数可以不相同,但是类型相同
例:以family为例
建表语句:

create table t_family
(name string,families array<string>)
row format delimited fields terminated by '\t'
collection iterms terminated by ',';

map(映射)

特点:key-value可以不相同,个数也可以不同。
数据格式:zhangsan age:27,salary:20000,adress:beijing

create table user_info
(name string,info map<string,string>)
row format delimieted fields terminated by '\t' 
collection items terminated by ','
map keys terminated by ':';

struct(对象)

特点:个数相同,类型相同
以stu(name,info)为例
数据格式:ghs 26,123456,shanghai,695

`create table stu_info
(name string, 
info struct<age:int,id:string,address:string,score:double>)
row format delimted fields terminated by '\t'
collection items terminated by ','`

select name,info.address from stu_info;

参考博客:https://blog.51cto.com/14048416/2342455

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值