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();
相关推荐
飞翔的佩奇10 分钟前
Java项目:基于SSM框架实现的劳务外包管理系统【ssm+B/S架构+源码+数据库+毕业论文】
java·mysql·spring·毕业设计·ssm·毕业论文·劳务外包
喵叔哟18 分钟前
第7章:Neo4j索引与约束
数据库·oracle·neo4j
Winn~1 小时前
MySQL行锁、记录锁、间隙锁、临建锁、意向锁、表锁
数据库·mysql
snowful world1 小时前
PolyU Palmprint Database掌纹识别数据集预处理(踩坑版)
数据库·人工智能·opencv
YuTaoShao1 小时前
Java八股文——MySQL「存储引擎篇」
java·开发语言·mysql
Mylvzi1 小时前
【MySQL 从 0 讲解系列】深入理解 GROUP BY 的本质与应用(含SQL示例+面试题)
数据库·sql·mysql
Forest_HAHA2 小时前
<6>-MySQL表的增删查改
数据库·mysql
blammmp2 小时前
Redis: List类型
数据库·redis·缓存
董可伦2 小时前
Docker 安装 Oracle 12C
docker·oracle
Leo.yuan2 小时前
数据挖掘是什么?数据挖掘技术有哪些?
大数据·数据库·人工智能·数据挖掘·数据分析