1、建表语句
1.1、分区表
create table if not exists tab_partition(
id int,
name string,
age int
)
PARTITIONED BY (year string , month string)
row format delimited
fields terminated by ','stored as orc;
1.2、分桶表
create table if not exists tab_bucket(
id int,
name string,
age int
)
clustered by (id) into 4 buckets
row format delimited
fields terminated by ','stored as orc;
2、区别
2.1、分区表是表内字段,分桶表是表外字段
2.2、分区表是个文件夹,分桶表是个文件
2.3、分桶表相对于分区表是更细粒度的划分,管理数据。
3、分桶表是用来解决什么问题的?
分桶表主要是针对大表,提高查询性能的