分区表和纬度表的创建

本文详细介绍如何在Hive中创建包含数组(array)和映射(map)等复杂数据类型的表,并演示了数据加载、查询及特定字段的访问过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.创建复杂类型的表(array)
create table qq1(id int,name string,xingge array<string>)
row format delimited fields terminated by ' '
collection items terminated by ',';


2.数据源
101 zs haha,hehe,heihei
102 ls haha,gaga,wawa

3.载入数据
hive> load data local inpath '/home/hadoop/qq1.txt' into table qq1;

4.查看
> select * from qq1;
OK
101 zs ["haha","hehe","heihei"]
102 ls ["haha","gaga","wawa"]


查看数组字段中某一个值
hive> select name,xingge[0] from qq1;


------------------------
1.复杂类型map使用
create table qq2(id int,name string,score map<string,int>)
row format delimited fields terminated by ' '
collection items terminated by ','
map keys terminated by ':';


2.数据源
101 zs 'math':90,'china':99,'art':98
102 ls 'math':50,'china':30,'art':10


3。
hive> load data local inpath '/home/hadoop/qq2.txt' into table qq2;

4.查看
hive> select * from qq2;
OK
101 zs {"'math'":90,"'china'":99,"'art'":98}
102 ls {"'math'":50,"'china'":30,"'art'":10}

查看map中 某一个值
hive> select name,score['math'] from qq2;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值