[PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)]mysql
在建表時,指定了PARTITIONED BY ,這個表稱爲分區表
PARTITIONED BY 以什麼分區sql
MR: 在MapTask輸出key-value時,爲每一個key-value計算一個區號,同一個分區的數據,會被同一個reduceTask處理
這個分區的數據,最終生成一個結果文件!
經過分區,將MapTask輸出的key-value通過reduce後,分散到多個不一樣的結果文件中!
Hive: 將表中的數據,分散到表目錄下的多個子目錄(分區目錄)中oop
多級分區表,有多個分區字段
create external table if not exists learnwork.deptpart2(
deptno int,
dname string,
loc int
)
PARTITIONED BY(area string,province string)
row format delimited fields terminated by '\t';orm
create external table if not exists learnwork.deptpart3(
deptno int,
dname string,
loc int
)
PARTITIONED BY(area string)
row format delimited fields terminated by '\t'
location 'hdfs://hadoop101:9000/deptpart3';hadoop
show partitions 表名string
alter table 表名 add partition(分區字段名=分區字段值) ;it