开启动态分区
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
添加列
alter table employee add columns (yoj String);
查看表结构
describe employee;
加载数据
load data local inpath '/data/sample.txt' overwrite into table employee;
创建分区表
create table emp_part(eid int,ename string,salary string,node string)
partitioned by (yoj string)
row format delimited
fields terminated by '\t'
lines terminated by '\n';
加载分区数据
load data local inpath '/data/sample.txt' overwrite into table emp_part partition (yoj='2018');
创建动态分区表
--添加数据
insert into table emp_part partition (yoj)
select eid,name,salary,destination,yoj from employee;
分区字段必须是最后一个字段
查看分区
show partitions emp_part;