oracle 插入或者更新大量数据(1W条以上),时间多少?

shabi09 2011-08-09 01:44:20
oracle 插入或者更新大量数据(1W条以上),时间多少?
使用过程写一个插入或者更新的语句,一般插入或者更新所需要的时间是多久 怎么我写的一个更新或者插入的 用了6分多钟的时间才插入1W多条。。。。是不是过程写的不行 还是什么的?
...全文
4435 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
夏笙 2021-07-09
  • 打赏
  • 举报
回复

怎么解决的 我也遇到了这么问题

shabi09 2011-08-15
  • 打赏
  • 举报
回复
那个lfywy 能不能贴个具体点例子出来呢?
lfywy 2011-08-12
  • 打赏
  • 举报
回复
给你提一个建议:最好把处理好的数据放在内存表里,然后采用批量插入的方式,这样肯定比你这个快!估计只要几秒罢了。另外尽量优化你得SQL语句
shabi09 2011-08-12
  • 打赏
  • 举报
回复
搞定了 重构方法。。。之前插入数据要20多分钟哦 ,现在只要50多秒钟。。。。。。
youqi1984 2011-08-11
  • 打赏
  • 举报
回复
如果可以使用批量绑定。一次更新
薛定谔之死猫 2011-08-11
  • 打赏
  • 举报
回复
要快速就重构方法,尽量使用SQL语句解决逻辑,避免使用循环,另外插入速度还与目标表的结构有关系,比如建的索引等
shabi09 2011-08-11
  • 打赏
  • 举报
回复
没有人回复么。。。。从A表查出gs_id,km_id je_id 然后在跟B表进对比gs_id,km_id,找出B表中的主键col_id 然后用col_id 跟C表中的主键比较 如果存在的话就更新,不存在就插入数据
shabi09 2011-08-10
  • 打赏
  • 举报
回复
你确定这个 比不用这个的速度要快?
yangqm22 2011-08-09
  • 打赏
  • 举报
回复
open gd_fy for select qijian,kmbh,gsdm,sum(jine) from sap_zfi001 where qijian =qihao group by qijian,kmbh,gsdm
union all select qijian,kmbh,gsdm,sum(jine) from sap_zfi001 where qijian =syqh group by qijian,kmbh,gsdm;
可以合并成为一个,为什么分两个。

execute immediate 。。。。using je_id,col_id,qijian1;
直接写语句不就行了。不要使用execute immediate ,直接写insert ...values 或update
shabi09 2011-08-09
  • 打赏
  • 举报
回复
一万多次 时间是6分多钟。。。。。给点建议
horizonlyhw 2011-08-09
  • 打赏
  • 举报
回复
loop循环了多少次?
每次的时间是多少?
shabi09 2011-08-09
  • 打赏
  • 举报
回复
上面的有几张表 我该过了 换成table1, table2了 还有个没有改过来 (科目动态表2--table2)

给点意见 新手!
shabi09 2011-08-09
  • 打赏
  • 举报
回复
create or replace procedure proc1_1_1(qihao in out varchar2)
is
gs_id varchar2(50); --公司编号
km_id varchar2(50); --科目编号
qhyf number;--时间变量1
qhyf1 varchar2(50);--时间变量2
qijian1 varchar2(50);--期号
syqh varchar2(50);--上月份期号
je_id number; --累计费用
col_id varchar2(100);--主键
kcount number;
kcount1 number;
type cur is ref cursor ;--定一个游标
gd_fy cur ;

begin
--求上月份期号如果这个月是1月份,就把上月累计设置为0
if( substr(qihao,length(qihao)-1,length(qihao))='01') then
syqh := '';
else
qhyf := to_number(substr(qihao,length(qihao)-1,length(qihao)));
qhyf := qhyf-1;
if(length(qhyf)=1) then
qhyf1 := '0'||to_char(qhyf) ;
else
qhyf1 := to_char(qhyf);
end if;

syqh := substr(qihao,1,length(qihao)-2)||qhyf1 ;
end if;
dbms_output.enable(9999999999999);
dbms_output.put_line('souser'||syqh);
open gd_fy for select qijian,kmbh,gsdm,sum(jine) from sap_zfi001 where qijian =qihao group by qijian,kmbh,gsdm
union all select qijian,kmbh,gsdm,sum(jine) from sap_zfi001 where qijian =syqh group by qijian,kmbh,gsdm;
loop
fetch gd_fy into qijian1,km_id,gs_id ,je_id;
select count(*) into kcount from table1 where col12_3 = km_id and col12_6 =gs_id ;
if(kcount =1) then
select col12_1 into col_id from table1 where col12_3 = km_id and col_1_1_12_6 =gs_id ;
select count(*) into kcount1 from table2 where col12_1 =col_id and it_state = 4||qijian1;
if(qijian1=qihao) then
if(kcount1 =0) then
execute immediate 'insert into table2 (col12_1,it_state,col12_14) values(:1,4||:2,:3)'using col_id,qijian1,je_id;
commit;
dbms_output.put_line('本月累计insert--'||je_id);
else
execute immediate 'update 科目动态表2 set col12_14=:1 where col12_1=:2 and it_state=4||:3 'using je_id,col_id,qijian1;
commit;
dbms_output.put_line('本月累计update--'||je_id);
end if;
end if;
if(qijian1=syqh) then
if(kcount1 =0) then
execute immediate 'insert into table2 (col12_1,it_state,col12_15) values(:1,4||:2,:3)'using col_id,qijian1,je_id;
commit;
dbms_output.put_line('上月累计insert--'||je_id);
else
execute immediate 'update 科目动态表2 set col12_15=:1 where col12_1=:2 and it_state=4||:3'using je_id,col_id,qijian1;
commit;
dbms_output.put_line('上月累计update--'||je_id);
end if;
end if;
end if;
end loop;
close gd_fy;
秋雨飘落 2011-08-09
  • 打赏
  • 举报
回复
对,代码贴出来给你分析,呵呵~~

这个速度和服务器有关系~~
luoyoumou 2011-08-09
  • 打赏
  • 举报
回复
-- 代码不贴出来,再多的问题也是白搭!

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧