command is too large: 853488551 bytes (max: 256000000)

使用postgresql时出现的问题
创建表时出现的问题

create table  enterprise_wide_table as
select 
a.entname,b.code_name as area,a.dom
,c.nic_id
,d.fulltitle
,a.opscope,a.entstatus 
,a.regcap ,a.esdate
,date_part('year',now()) - to_char(a.esdate,'yyyy')  as year
,e.ancheyear ,e.netinc ,e.liagro ,e.maibusinc ,e.vendinc 
,a.empnum ,a.enttype_name
,case 
when  a.empnum >= '1000' and replace(e.maibusinc,'万','')>='40000' then '大'
when   '1000'>a.empnum and replace(e.maibusinc,'万','')>='300' and '40000'>e.maibusinc and e.maibusinc>='2000' then '中'
when   '300'>a.empnum and replace(e.maibusinc,'万','')>='20' and '2000'>e.maibusinc and e.maibusinc>='300' then '小'
when  a.empnum< '20' and replace(e.maibusinc,'万','')<'300' then '微'
else 'NULL'
end as enterprise_scale
,f.pl_nums ,f.pr_nums 
from 
 public.chongqign_area_code_temporary  a
inner join public.chongqign_area_code_csv b on a.domdistrict = b.code::varchar
left join public.company_class c on a.entid = c.entid and  (substr(c.nic_id ,1,1)='B' or substr(c.nic_id ,1,1)='C' or substr(c.nic_id ,1,1)='D')
left join public.code_nic  d on substr(c.nic_id ,1,1)  = d.code  
left join public.company_ar_assetsinfo e  on e.entid  = a.entid  
left join public.nacao_techindex  f  on f.entid  = a.entid  

SQL 错误 [XXUUU]: ERROR: command is too large: 853488551 bytes (max: 256000000)
在这里插入图片描述

出现问题原因

创建表太大了,内存不够用了

解决方案
使用 limit 0 先创建表,在insert into table 导入数据

create table  enterprise_wide_table as 
select 
a.entname,b.code_name as area,a.dom
,c.nic_id
,d.fulltitle
,a.opscope,a.entstatus 
,a.regcap ,a.esdate
,date_part('year',now()) - to_char(a.esdate,'yyyy')  as year
,e.ancheyear ,e.netinc ,e.liagro ,e.maibusinc ,e.vendinc 
,a.empnum ,a.enttype_name
,case 
when  a.empnum >= '1000' and replace(e.maibusinc,'万','')>='40000' then '大'
when   '1000'>a.empnum and replace(e.maibusinc,'万','')>='300' and '40000'>e.maibusinc and e.maibusinc>='2000' then '中'
when   '300'>a.empnum and replace(e.maibusinc,'万','')>='20' and '2000'>e.maibusinc and e.maibusinc>='300' then '小'
when  a.empnum< '20' and replace(e.maibusinc,'万','')<'300' then '微'
else 'NULL'
end as enterprise_scale
,f.pl_nums ,f.pr_nums 
from 
public.company  a
inner join public.chongqign_area_code_csv b on a.domdistrict = b.code::varchar
left join public.company_class c on a.entid = c.entid and  (substr(c.nic_id ,1,1)='B' or substr(c.nic_id ,1,1)='C' or substr(c.nic_id ,1,1)='D')
left join public.code_nic  d on substr(c.nic_id ,1,1)  = d.code  
left join public.company_ar_assetsinfo e  on e.entid  = a.entid  
left join public.nacao_techindex  f  on f.entid  = a.entid  limit 0
 
insert into enterprise_wide_table
select 
a.entname,b.code_name as area,a.dom
,c.nic_id
,d.fulltitle
,a.opscope,a.entstatus 
,a.regcap ,a.esdate
,date_part('year',now()) - to_char(a.esdate,'yyyy')  as year
,e.ancheyear ,e.netinc ,e.liagro ,e.maibusinc ,e.vendinc 
,a.empnum ,a.enttype_name
,case 
when  a.empnum >= '1000' and replace(e.maibusinc,'万','')>='40000' then '大'
when   '1000'>a.empnum and replace(e.maibusinc,'万','')>='300' and '40000'>e.maibusinc and e.maibusinc>='2000' then '中'
when   '300'>a.empnum and replace(e.maibusinc,'万','')>='20' and '2000'>e.maibusinc and e.maibusinc>='300' then '小'
when  a.empnum< '20' and replace(e.maibusinc,'万','')<'300' then '微'
else 'NULL'
end as enterprise_scale
,f.pl_nums ,f.pr_nums 
from 
 public.chongqign_area_code_temporary  a
inner join public.chongqign_area_code_csv b on a.domdistrict = b.code::varchar
left join public.company_class c on a.entid = c.entid and  (substr(c.nic_id ,1,1)='B' or substr(c.nic_id ,1,1)='C' or substr(c.nic_id ,1,1)='D')
left join public.code_nic  d on substr(c.nic_id ,1,1)  = d.code  
left join public.company_ar_assetsinfo e  on e.entid  = a.entid  
left join public.nacao_techindex  f  on f.entid  = a.entid
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值