hive动态分区表、分桶表、既分区又分桶表的应用

本文介绍了Hive中的动态分区表、分桶表以及同时分区和分桶的表的应用。通过创建临时表并导入数据的方式展示了如何实现动态分区效果,并探讨了在分区表中使用分桶的重要性及注意事项,例如在导入数据时避免指定分桶字段。
摘要由CSDN通过智能技术生成

hive动态分区表、分桶表、既分区又分桶表的应用

hive 动态分区表
partitioned by(colName Type)

create table tableName(
.......
.......
)
partitioned by (colName colType [comment '...'],...)

例如

create table dy_part1(
sid int,
name string,
gender string,
age int,
academy string
)
partitioned by (dt string)
row format delimited fields terminated by ','
;

动态分区表导入数据要建立一个临时表,不然没有分区的效果
创建临时表

create table temp_part1(
sid int,
name string,
gender string,
age int,
academy string,
dt string
)
row format delimited 
fields terminated by ','
;
加载数据
load data local inpath '路径' into table temp_part1;

动态导入数据

insert into dy_part1 partition(dt) select sid,name,gender,age,academy,dt from temp_part1;

hive 分桶表

drop table student;
create table student(
sno int,
name string,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值