溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

db2快速創(chuàng)建千萬級模擬數(shù)據(jù)

發(fā)布時(shí)間:2020-07-03 13:05:30 來源:網(wǎng)絡(luò) 閱讀:573 作者:18620626259 欄目:MySQL數(shù)據(jù)庫

利用python生成導(dǎo)入文件

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
path = r"F:\alien_invasion\DATA_BLKLISTS01A.del"
list = open(path,'w')
count1 = 1
print("開始執(zhí)行!" )
for i in range(10000000):
    i = i+1
    count1 +=1
    randomcount = random.randint(0,9)
    print("""%s,"8613%s%08d",1,1,"remarks",""" % (i,str(randomcount),count1))
    list.writelines("""%s,"8613%s%08d",1,1,"remarks",\n""" % (i,str(randomcount),count1))
    #函數(shù) writelines(list)函數(shù)writelines可以將list寫入到文件中,但是不會(huì)在list每個(gè)元素后加換行符,所以如果想每行都有換行符的話需要自己再加上。
print ("執(zhí)行結(jié)束!")
list.close()


利用db2 load工具導(dǎo)入數(shù)據(jù)

db2 connect to  數(shù)據(jù)庫名

創(chuàng)建500w數(shù)據(jù)表

db2 "CREATE TABLE XIFENFEI_LOAD(col1  INT NOT NULL primary key,
                                col2  CHAR(100) NOT NULL,
                                col3  VARCHAR(20) NOT NULL,
                                col4  VARCHAR(20) NOT NULL,
                                col5  VARCHAR(20) NOT NULL)"
                               
導(dǎo)入500萬數(shù)據(jù)                                                                                                                
db2 load from /tmp/DATA_BLKLISTS01.del of del insert into XIFENFEI_LOAD1 nonrecoverable


創(chuàng)建1000w數(shù)據(jù)表
db2 "CREATE TABLE XIFENFEI_LOAD4(col1 BIGINT  NOT NULL primary key,
                                col2  CHAR(100) NOT NULL,
                                col3  VARCHAR(20) NOT NULL,
                                col4  VARCHAR(20) NOT NULL,
                                col5  VARCHAR(20) NOT NULL)" 
導(dǎo)入1000萬數(shù)據(jù)
db2 load from /tmp/DATA_BLKLISTS01A.del of del insert into XIFENFEI_LOAD4 nonrecoverable


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI