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();
相关推荐
010不二1 分钟前
基于Appium爬虫文本导出可话个人动态
数据库·爬虫·python·appium
火山引擎开发者社区4 分钟前
云数据库 MySQL 2025 运维革新:大版本升级无忧+蓝绿零停机+存储自动扩容全覆盖
运维·数据库·mysql
杜子不疼.1 小时前
Spring AI 与向量数据库:构建企业级 RAG 智能问答系统
数据库·人工智能·spring
山峰哥1 小时前
Python爬虫实战:从零构建高效数据采集系统
开发语言·数据库·爬虫·python·性能优化·架构
_OP_CHEN2 小时前
【C++数据结构进阶】从B + 树 / B * 树到数据库索引:B树的进化之路与 MySQL 实战解析
数据结构·数据库·b树·mysql·innodb·b+树·mylsam
云老大TG:@yunlaoda3608 小时前
华为云国际站代理商TaurusDB的成本优化体现在哪些方面?
大数据·网络·数据库·华为云
TG:@yunlaoda360 云老大8 小时前
华为云国际站代理商GeminiDB的企业级高可用具体是如何实现的?
服务器·网络·数据库·华为云
最贪吃的虎10 小时前
Git: rebase vs merge
java·运维·git·后端·mysql
QQ142207844910 小时前
没有这个数据库账户,难道受到了sql注入式攻击?
数据库·sql
残 风10 小时前
pg兼容mysql框架之语法解析层(openHalo开源项目解析)
数据库·mysql·开源