mysql通过存储过程生成测试数据50万条

1:准备表

CREATE TABLE tmp_test (
    id VARCHAR(16),
    NAME VARCHAR ( 16 ),
    age INT ( 3 ),
    remark VARCHAR ( 128 ),
    jobName CHAR ( 16 ),
school CHAR ( 32 ) 
);

2:创建存储过程

#声明结束符号为$$
delimiter $$ 
create procedure insertTmpTest(IN size int)
BEGIN
    declare i int default 1;
    while(i<size)do
        insert into tmp_test values(substr(uuid(),1,16),substr(uuid(),1,10),FLOOR(RAND()*100),uuid(),substr( uuid(),1,12),substr( uuid(),1,12));
        set i=i+1;
    end while;
END$$ 
#声明分号为结束符号
delimiter ; 

3:查看一下结果

show create procedure insertTmpTest

4:调用

call insertTmpTest(100000);

 

posted @ 2023-06-14 15:19  鸭猪是的念来过倒  阅读(35)  评论(0编辑  收藏  举报