1,两张表,ta,tb
create table ta(id int,name string) partition(year int,month int);
create table tb(id int,name string) partition(year int,month int);
2,insert ta select tb
一,插入ta的静态分区
insert into ta partition(year=2019,month=4) select id,name from tb [where year=2019 and month=3];
此时不能用select * from tb; 代替 select id,name from tb; 因为分区字段year和month 在ta中已经有值,在tb中查询出其他字段即可,select * 包含分区字段,而此时不需要分区字段的值
如果两个表有大量字段怎么办?还不是都写出来。。。
二,插入ta的动态分区
insert into ta partition(year,month) select * from tb [where year=2019 and month=3];
此时的分区字段在ta中没有值,会被tb中的分区字段值所覆盖,所有可以这么写
三,部分动态,部分静态
insert into ta partition(year=2019,month) select id,name,month from tb [where year=2019 and month=3];
需要把动态分区列出,同理,因为动态分区month没有值,需要被覆盖