impala分区表用insert into...select插入数据

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没有值,需要被覆盖

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值