问题
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