hive 分区和分桶

一、为啥分区

hive 为了避免全表查询,从而引进分区,将数据按目录进行划分,减少不必要的查询,从而提高效率

二、hive的分区和mysql分区的区别

mysql的分区字段用的是表内字段,hive的分区字段采用表外字段,也就是使用伪字段,分区字段在创建表的时候指定

分区的关键字:partitioned by(字段)

三、静态分区练习

create table if not exists u1(
id int,
name string,
age int
)
partitioned by(dt string)
row format delimited fields terminated by ' '
stored as textfile
;


1 xm1 16
2 xm2 18
3 xm3 22

11 xh1 26
22 xh2 28
33 xh3 30

load data local inpath '/home/u1' into table u1 partition(dt="2018-10-14");
load data local inpath '/home/u115' into table u1 partition(dt="2018-10-15");

四、二级分区

create table if not exists u2(
id int,
nam
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值