1.创建分区表
开启分区
set hive.exec.dynamic.partition=true;
开启动态分区
set hive.exec.dynamic.partition.mode=nonstrict;
create table t2(id string,name string)
partitioned by (year string,month string)
Row Format Delimited Fields Terminated By '|';
普通列和分区列是分开的,别写重复
2.插入数据
这只是插入单个数据. 需要指定分区位置.
insert into t2 partition(year='2018',month='05')valus('1001','Nike');
批量导入数据到分区,也需要指定位置,这是强制导入某一分区 .
load data local inpath '/home/user1/emp.txt' overwrite into table t1 partition(year = "2018",month = "07");
网友评论