hive动态分区表、分桶表、既分区又分桶表的应用
hive 动态分区表
partitioned by(colName Type)
create table tableName(
.......
.......
)
partitioned by (colName colType [comment '...'],...)
例如
create table dy_part1(
sid int,
name string,
gender string,
age int,
academy string
)
partitioned by (dt string)
row format delimited fields terminated by ','
;
动态分区表导入数据要建立一个临时表,不然没有分区的效果
创建临时表
create table temp_part1(
sid int,
name string,
gender string,
age int,
academy string,
dt string
)
row format delimited
fields terminated by ','
;
加载数据
load data local inpath '路径' into table temp_part1;
动态导入数据
insert into dy_part1 partition(dt) select sid,name,gender,age,academy,dt from temp_part1;
hive 分桶表
drop table student;
create table student(
sno int,
name string,