What is the fastest way to insert 1 mln+ records in DB2 table?

偶尔善良 提交于 2019-12-24 04:18:13

问题


In C# I have 1mln+ records which are necessary to insert into DB2 table. What is the fastest way to insert 1 mln+ records in DB2 table?

I've check several way and the fastest is by 1000 rows basing on the following request: INSERT INTO tbl (id, rel) values (1, 2), (2,3),...

Are the any other ideas?


回答1:


Try wth something like that for 1000 records:

INSERT INTO table
  SELECT                                       
  cast (RAND()*50000 as numeric(6)) AS id,  
  cast (RAND() as varchar(30)) AS rel,       
  FROM qsys2/COLUMNS                           
   fetch first 1000 rows only                    

change table and the field nature/length in relation with you table.

I assumed with that

cast (RAND()*50000 as numeric(6)) AS id

that id is numeric 6 byte

with the last line you limit 1000 rows insert



来源:https://stackoverflow.com/questions/21284928/what-is-the-fastest-way-to-insert-1-mln-records-in-db2-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!