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

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

问题描述

在 C# 中,我有 100 万多条记录需要插入到 DB2 表中.在 DB2 表中插入 100 万条记录的最快方法是什么?

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?

我已经检查了几种方法,最快的是根据以下请求检查 1000 行:INSERT INTO tbl (id, rel) 值 (1, 2), (2,3),...

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),...

还有其他想法吗?

推荐答案

用类似的方法尝试 1000 条记录:

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                    

更改 table 以及与您的表格相关的字段性质/长度.

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

我假设了

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

那个id是数字6字节

最后一行限制插入 1000 行

with the last line you limit 1000 rows insert

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

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