mysql如何快速生成测试大数据库

快速生成1000W测试数据库;

创建测试表:

sql 复制代码
create table user (  
    id int(10) not null auto_increment,   
    uname  varchar(20) ,  
    regtime  char(30)  ,  
    age  int(11)   ,
    primary key (id)
)  
engine=myisam default charset=utf8 collate=utf8_general_ci  ,
auto_increment=1 ;

编写存储过程:

sql 复制代码
delimiter $$
SET AUTOCOMMIT = 0$$
 
create  procedure test()
begin
declare v_cnt decimal (10)  default 0 ;
dd:loop
          insert  into user values
    (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50),
        (null,rand()*10,now(),rand()*50);
      commit;
        set v_cnt = v_cnt+10 ;
           if  v_cnt = 10000000 then leave dd;
          end if;
         end loop dd ;
end;$$
 
delimiter ;

调用存储过程:

sql 复制代码
call test();
相关推荐
努力努力再努力wz2 分钟前
【Qt入门系列】:QLabel控件详解:从文本显示到图片展示,再到内容布局与伙伴机制
android·开发语言·数据结构·数据库·c++·qt·mysql
Volunteer Technology3 分钟前
Flink编程模型与API(二)
大数据·数据库·flink
流星白龙7 分钟前
【MySQL高阶】5.MySQL服务器简介
服务器·mysql·adb
流星白龙11 分钟前
【MySQL高阶】9.在一台机器上运行多个MySQL实例
数据库·mysql·adb
Rick199311 分钟前
MySQL 优化器会选择【最小、最精准、最高效】的索引
数据库·mysql
mN9B2uk1714 分钟前
MySQL命令行导出数据库
c语言·数据库·mysql
铁皮哥25 分钟前
【后端开发】什么是守护线程,和普通线程有什么区别?
java·开发语言·数据库·人工智能·python·spring·intellij-idea
~央千澈~26 分钟前
《ZAKU渗透论:卓伊凡的2026渗透工程》第三章:Web攻击原理(上)——注入与SQL注入
数据库·sql·oracle
AI人工智能+电脑小能手33 分钟前
【大白话说Java面试题 第86题】【Mysql篇】第16题:MySQL 中锁的种类与行锁实现原理?
java·开发语言·数据库·mysql·面试
染指111033 分钟前
14.LangChain框架5-文档切分
数据库·人工智能·ai·langchain