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 <>;

猜你喜欢

转载自blog.csdn.net/sinat_34789167/article/details/81128970