在DB2表中插入1毫升+记录的最快方式是什么? [英] What is the fastest way to insert 1 mln+ records in DB2 table?

查看:122
本文介绍了在DB2表中插入1毫升+记录的最快方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中,我有1mln +记录是插入DB2表所必需的。
在DB2表中插入1 mln +记录的最快方式是什么?我已经检查了几种方法,最快的是基于以下请求的1000行:
INSERT INTO tbl(id,rel)值(1, 2),(2,3),...



是否有其他想法?

解决方案

尝试一下这样的1000条记录:

  INSERT INTO表
SELECT
cast(RAND()* 50000 as numeric(6))AS id,
cast(RAND()as varchar(30))AS rel,
FROM qsys2 / COLUMNS
fetch前1000行只有

更改和字段性质/与您相关的长度表。



我假设

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

id 是数字6字节



最后一行你限制1000行insert


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?

解决方案

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

这篇关于在DB2表中插入1毫升+记录的最快方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆