hive分区表

本文详细介绍了Hive中分区表的概念及其使用方法。包括如何创建分区表、添加分区、插入数据等操作,并通过实例展示了Hive如何利用分区来优化查询性能。

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

Partition 对应于数据库的 Partition 列的密集索引

在 Hive 中,表中的一个 Partition 对应于表下的一个目录,所有的 Partition 的数据都存储在对应的目录中

例如:
test表中包含 date 和 city 两个 Partition
则对应于date=20130201, city = bj 的 HDFS 子目录为:
/warehouse/test/date=20130201/city=bj
对应于date=20130202, city=sh 的HDFS 子目录为;
/warehouse/test/date=20130202/city=sh

创建表

create table partition_table(id int,name string) partitioned by(age int,high int);
alter table partition_table add partition (age=20,high=180);

insert into hive_test.partition_table PARTITION (age,high) values (1,'xubin',20,180);

insert overwrite table partition_table partition (age=20,high=180) select id,name from external_table where age =20 and high = 180;

insert overwrite table partition_table partition (age=21,high=180) select id,name from external_table where age =21 and high = 180;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值