Hive手册入门篇

基于hadoop的数仓工具,将结构画的数据映射为一张表,并提供hsql的查询功能,本质是将sql语句转化为MapReduce的任务进行执行,底层由HDFS来提供数据支持。存储用HDFS,计算用MapReduce

数据类型

数据类型备注
tinyint1字节有符号整数,范围-128~127
samllint2字节有符号整数,范围-32768~32767
int4字节有符号整数,范围-2^31 ~2^31-1
bigint8字节有符号整数,范围-2^63 ~2^63-1
float4字节单精度浮点数
double8字节双精度浮点数
decimal任意精度的带符号小数
booleantrue/false
string变长字符串
varchar变长字符串
char定长字符串
date日期
timestamp时间戳
binary字节数组,存储变长的二进制数据

集合类型

数据类型备注
struct结构体
map键值对,key和value都是string类型
array组,可以存多个数据,用逗号隔开

示例:

create table test(
man struct<name:string,agt:int> comment "个人信息"
,marry_info map<string,string> comment "婚姻信息"
,hobby array<string> comment "爱好"
);
-- 插入数据
insert into test
select name_struct("name","小明","age",12)
,str_to_map("小明:单身,时长:3年")
,array("打球,游泳,滑雪")

--查询数据
select 
a.man.name
,a.marry_info["小明"]
,a.hobby[0]
from
test a 

建表

create table test(
id int comment "序号"
,start_time timestamp comment "开始时间"
,name string comment "姓名"
)
comment "小小牛学院信息"

插入

-- 部分字段插入
insert into test(id,name)
select 33882,"刚子"

-- 全字段插入
insert into test
select 33882,current_timestamp(),"刚子"

查询

select * from test a where a.id=33882

删除

-- 覆盖重写
insert overwrite table test
select * from test a where a.id=33

更新

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值