hive分区表几大注意事项

本文介绍了Hive中分区表的概念及其如何优化数据查询过程。通过对比非分区表,阐述了分区表如何减少不必要的全表扫描,从而显著降低数据库压力并提高查询效率。此外,还提供了创建和使用Hive分区表的具体步骤。

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

分区表:
1.问题的引入
1).bf_log
/usr/hive/warehouse
20170910.log
20170922.log
我想分析某一天的数据,如果按照以上的就会扫描全表,从而增加了数据库的压力,引入了分区表
2)./usr/hive/warehouse
20170910/
20170910.log
20170922/
20170922.log
2.分区表实际上就是对应一个HDFS文件的文件系统上一个文件夹,该文件下就是该分区所有数据的文件,hive中的分区就是分目录,就是把一个大的数据集根据业务需求拆分成更小的数据集.就跟Java中的查询时通过where子句中的表达式来选择分区,这样的查询效率会提高很多。
create table db_hive.dept_partition(
deptno int,dname string,loc string)
partitioned by(month string)
row format delimited fields terminated by ‘\t’;
load data local inpath ‘数据路径’ into table db_hive.dept_partition partition(month=’2017-09-12’);
注意事项:
create table db_hive.dept_partition(
deptno int,dname string,loc string)
row format delimited fields terminated by ‘\t’;
create table db_hive.dept_partition(
deptno int,dname string,loc string)
partitioned by(month string)
row format delimited fields terminated by ‘\t’;
向hdfs上传对应的数据
msck repair table db_hive.dept_partition;就可以加载导数据
alert table db_hive.dept_partition add partition(day string);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值