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