涉及百万级,千万级测试数据基础构建,我们不可能通过程序批量加入或者insert的方式进行数据构建,以下介绍一种简单的方法,可以构造任意数据表(包括时间格式,浮点数等)
首先,使用下面的语句将,数据格式导出
-- Start of generated script for 192.168.0.85-INFO85-INFOSPY (db2inst1)
-- Oct-11-2008 at 14:53:28
EXPORT TO 'C:\DATA_WHITELISTS_R.del' OF DEL
SELECT * FROM "DB2INST1"."DATA_WHITELISTS_R";
#SYNC 10;
-- End of generated script for 192.168.0.85-INFO85-INFOSPY (db2inst1)
通过一个简短python脚本构建你所需要的测试数据
# -*- coding: cp936 -*-
#===============================================================================
# 制作百万白名单数据
#===============================================================================
import random
path = r"C:\20W白名单.del"
list = open(path,'w')
count1 = 00000001
#print "开始执行!"
for i in range(200000):
i = i+1
count1 +=1
#print count1
# print "Remarks"
#print "0"
randomcount = random.randint(0,9)
print """%s,"8613%s%08d",1,1,"remarks",,\n""" % (i,str(randomcount),count1)
list.writelines("""%s,"8613%s%08d",1,1,"remarks",,\n""" % (i,str(randomcount),count1))
print "执行结束!"
list.close()
使用以下命令将生成del文件导入数据库,提供两种方式:
在客户端使用的脚本:
LOAD CLIENT FROM "C:\DATA_BLKLISTS01.del" OF DEL METHOD P (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) INSERT INTO DB2INST1.DATA_BLKLISTS (LIST_ID, BLK_TYPE, NE_ID, SENDER, SOURCE_TON, SOURCE_NPI, RECEIPTOR, OUTLAW_TIME, OUTLAW_NUMBER, BGN_TIME, END_TIME, BLK_DESC, SM_TYPE, ALARM_LEVEL) COPY NO INDEXING MODE AUTOSELECT
在服务器端使用的脚本:
LOAD FROM "\home\antispam\DATA_BLKLISTS01.del" OF DEL METHOD P (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) INSERT INTO DB2INST1.DATA_BLKLISTS (LIST_ID, BLK_TYPE, NE_ID, SENDER, SOURCE_TON, SOURCE_NPI, RECEIPTOR, OUTLAW_TIME, OUTLAW_NUMBER, BGN_TIME, END_TIME, BLK_DESC, SM_TYPE, ALARM_LEVEL) COPY NO INDEXING MODE AUTOSELECT