mysql隨機生成百萬條測試資料

2021-08-22 11:34:46 字數 830 閱讀 9631

mysql的隨機生成百萬條測試資料

今天跟大家分享的是mysql的如何生成百萬條測試資料。

首先我們需要有資料來源,可以是幾條資料如下圖。

然後執行一天的sql,如下:

insert into grzxmxb(orgname,cxlsh,czyh,checkname,checkorg,checkorgcode,username,certtype,usercertno,checktime,

queryreason,cxcl,sqlsh,欣欣,isfinish,repno,bgly,grrhzh,bgscsj,dataorgcode,reportdate,orgcode,createdate,sqcxyy,

sqyt,zt)select orgname,cxlsh,czyh,checkname,checkorg,checkorgcode,username,certtype,usercertno,checktime,queryreason,

cxcl,sqlsh,showtime,isfinish,repno,bgly,grrhzh,bgscsj,dataorgcode,reportdate,orgcode,createdate,sqcxyy,sqyt,zt from`grzxmxb` 

where id> =(selectfloor(rand()*(select max(id)from`grzxmxb`)))order by id limit 100;

就可以達到新增100條隨機資料了。

想達到更多隻需要把100改大,就好了 但是建議不要超過10萬,處理太慢,會影響效率。

而且我們可以根據自己的實際情況對sql,進行調整.id為表的主鍵。字段改為自己想要的表的字段就可以了。

SQL生成百萬隨機數 sqlserver

建表 表名tb 欄位id 必須是char型 create table tb id char 8 建立用於自動過濾重複值的唯一索引 表名tb 欄位id create unique index ix tb on tb id with ignore dup key go 插入隨機資料 setnocount...

mysql生成百萬級數量測試資料

首先我的生成table的 如下 set foreign key checks 0 table structure for user drop table ifexists user create table user username bigint 255 not null auto increme...

資料庫 利用Sql快速 高效的生成百萬條資料

執行以下sql即可生成100條資料 create table mytesttable as select rownum as id,to char sysdate rownum 24 3600 yyyy mm dd hh24 mi ss as inc datetime,trunc dbms rand...