Hive有分区表和分桶表这两个概念。
分区表
基本操作
Hive的分区是指将存储的数据进一步细分,相当于一个表的分目录。一个表内有多个分区表。
create table table_name (column_name column_type, ...) partitioned by (partition_column partition_type)
//例如 按天进行分区
create table dept_partition(deptno int, dname string, loc string)
partitioned by (day string)
row format delimited fields terminated by '\t';
注意:分区字段不能是表中已经存在的数据,可以将分区字段看作表的伪列。
load data时指定分区
load data inpath "/data/test.txt" into table dept_par