我有一个非常简单的查询,如下所示。
drop table if exists table1;
create table table1
select
account,
campaign_id,
customer_id,
type,
min(date) as date_min
from table2
where account in ('1','2') and campaign_id not in ('1','2','3')
group by account, campaign_id,customer_id,type;
但是,每次运行此命令时,都会收到此错误消息,提示“ java.io.IOException:连接被远程主机关闭”。我相信是因为数据太大。
有人建议我循环“插入”语句,并在空表中逐段添加数据。
所以我试图逐年添加数据。以下代码仅使用一年。我需要插入多次。
insert into loop_dk (account, campaign_id, customer_id, type, date_min)
select account,
campaign_id,
customer_id,
type,
min(date) as date_min
from dk
where account in ('1', '2')
and campaign_id not in ('1', '2', '3') and date between '2016-11-29' and '2017-11-29'
group by account, campaign_id, customer_id, type;
有人可以告诉我“插入”语句是否是好方法,或者建议我采取任何其他可防止上述错误消息的解决方案?
非常感谢您的帮助!