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 <>;
發佈了61 篇原創文章 · 獲贊 16 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章