hive的数据类型和视图

一。基本数据类型

int(tinyint,smallint,int,bigint)
float double
boolean
string
timestemp

二。复杂数据类型

array
	create table test_arr(id int,name string,hobby array<string>) row format delimited fields terminated by '\t' collection items terminated by ',';
	collection items terminated by ','指的是array里元素的分隔符
	数据导入:
	load data inpath '/' into table test_arr;
	查询:可以通过下标进行数据访问
	select hobby[0] from test_arr;
	如果没有就返回null
	
map
	建表时候的分隔符,从外到内依次指定
	create table test_map(id int,name string,piaofang map<string,bigdata>) row format delimited fields terminated by '\t' collection items terminated by ',' map keys terminated by ':';
	查询:
	select paiofang['paonan'] from test_map;
	
struct:类似于对象类型
	可以用于数据比较规整,数据中每个字段含义一样时
	create table test_struct(id int,name string,info struct<city:string,age:int,score:int>) row format delimited fields terminated by '\t' collection items terminated by ',';
	查询:
	通过.可以像.属性一样进行访问
	select info.city,info.score from test_struct;

三。视图
1.hive中只有逻辑视图,没有物化视图
逻辑视图:仅仅保存视图的语句,不进行执行
2.相当于sql语句的一个快捷方式,用于提高hql语句的可读性
3.hive中的视图不支持insert,delete,update操作
4.hive中的视图是在真正查询视图的时候才会执行
5.hive中的视图存储在元数据中,存的内容将就是视图代表的sql语句
create view my_view01 select …

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值