3,491
社区成员
发帖
与我相关
我的任务
分享
-- 我这里灌了 1亿条记录,你大概参考一下时间;
SQL> create table x(x int) ;
Table created
Executed in 0.069 seconds
SQL> begin
2 insert into x select rownum from dual connect by rownum <= 10000 ;
3 for x in 1..9999 loop
4 insert into /*+ append */x select * from x where rownum <= 10000;
5 commit ;
6 end loop ;
7 end ;
8 /
PL/SQL procedure successfully completed
Executed in 74.242 seconds
SQL> select count(*) from x ;
COUNT(*)
----------
100000000
Executed in 7.061 seconds
SQL> drop table x purge ;
Table dropped
Executed in 0.174 seconds
SQL>
if mod(i,1000)=0 then
commit;
end if;
也就是批量提交,不要一条一条的提交。
其中的1000可以测试看看是多少比较快,我插入了123456条记录,感觉100、1000、10000差别不大。