Hive的分割槽表入門

2021-10-01 03:47:30 字數 1267 閱讀 8717

資料分割槽的概念以及存在很久了,通常使用分割槽來水平分散壓力,將資料從物理上移到和使用最頻繁的使用者更近的地方,以及實現其目的。

hive中有分割槽表的概念,我們可以看到分割槽具重要效能優勢,而且分割槽表還可以將資料以一種符合邏輯的方式進行組織,比如分層儲存

分割槽表分別有靜態分割槽和動態分割槽

create table score(s_id string,c_id string, s_score int) partitioned by (month string) row format delimited fields terminated by '\t';
create table score2 (s_id string,c_id string, s_score int) partitioned by (year string,month string,day string) row format delimited fields terminated by '\t';
load data local inpath '/export/servers/hivedatas/score.csv' into table score partition (month='201806');
load data local inpath '/export/servers/hivedatas/score.csv' into table score2 partition(year='2018',month='06',day='01');
select * from score where month = '201806' union all select * from score where month = '201806';
show  partitions  score;
alter table score add partition(month='201805');
alter table score add partition(month='201804') partition(month = '201803');
注意:新增分割槽之後就可以在hdfs檔案系統當中看到表下面多了乙個資料夾

alter table score drop partition(month = '201806');

hive 分割槽表 Hive的DDL分割槽表建立

1.單分割槽表 建立表t user,指定分割槽hive xiaoliu create table t user id int,name string partitioned by country string row format delimited fields terminated by xia...

hive 分割槽表

partitioned by create table tb name name string partitioned by age int row format delimited fields terminated by t load data local inpath file path in...

hive分割槽表

partition對應於資料庫的 partition 列的密集索引 在 hive 中,表中的乙個 partition 對應於表下的乙個目錄,所有的 partition 的資料都儲存在對應的目錄中 例如 test表中包含 date 和 city 兩個 partition 則對應於date 201302...