hive手册之分区使用

介绍hive如何添加分区、删除分区、自定义分区以及分区插入数据

如何自定义分区:


create table test(name string,sex int) partitions (birth string, age string);
create table yxtest(name string,sex int)
partitioned by (month_id string)
row format delimited 
fields terminated by '|'
stored as textfile
;

添加分区

alter table test add partition (birth='1980', age='29');
alter table test  add partition (birth='1982', age ='28');
show partitions test;

删除分区

alter table test drop partition (birth='1980',age='30');

加载数据到指定分区:

load data local inpath '/home/hadoop/data.log' overwrite into table 
test partition(birth='1980-01-01',age='30');

向partition_test的分区中插入数据:

insert overwrite table partition_test partition(stat_date='20110728',province='henan') 
select member_id,name from partition_test_input where stat_date='20110728' and province='henan';
insert overwrite table table_name partition(<partition=''>)
select * from table_name where <>;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值