1. 程式人生 > >hive分割槽表幾大注意事項

hive分割槽表幾大注意事項

分割槽表:
1.問題的引入
1).bf_log
/usr/hive/warehouse
20170910.log
20170922.log
我想分析某一天的資料,如果按照以上的就會掃描全表,從而增加了資料庫的壓力,引入了分割槽表
2)./usr/hive/warehouse
20170910/
20170910.log
20170922/
20170922.log
2.分割槽表實際上就是對應一個HDFS檔案的檔案系統上一個資料夾,該檔案下就是該分割槽所有資料的檔案,hive中的分割槽就是分目錄,就是把一個大的資料集根據業務需求拆分成更小的資料集.就跟Java中的查詢時通過where子句中的表示式來選擇分割槽,這樣的查詢效率會提高很多。
create table db_hive.dept_partition(
deptno int,dname string,loc string)
partitioned by(month string)
row format delimited fields terminated by ‘\t’;
load data local inpath ‘資料路徑’ into table db_hive.dept_partition partition(month=’2017-09-12’);
注意事項:
create table db_hive.dept_partition(
deptno int,dname string,loc string)
row format delimited fields terminated by ‘\t’;
create table db_hive.dept_partition(
deptno int,dname string,loc string)
partitioned by(month string)
row format delimited fields terminated by ‘\t’;
向hdfs上傳對應的資料
msck repair table db_hive.dept_partition;就可以載入導資料
alert table db_hive.dept_partition add partition(day string);