快速生成500W测试数据库


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

创建测试表:

DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `uname` varchar(20) DEFAULT NULL COMMENT '账号',
  `pwd` varchar(20) DEFAULT NULL COMMENT '密码',
  `addr` varchar(80) DEFAULT NULL COMMENT '地址', `tel` varchar(20) DEFAULT NULL COMMENT '电话', `regtime` char(30) DEFAULT NULL COMMENT '注册时间', `age` int(11) DEFAULT NULL COMMENT '年龄', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

 

编写存储过程:

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,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10), (null,rand()*10,now(),rand()*50,rand()*10,rand()*10,rand()*10); commit; set v_cnt = v_cnt+10 ; if v_cnt = 5000000 then leave dd; end if; end loop dd ; end;$$ delimiter ;

 

调用存储过程:

call test();

转载于:https://www.cnblogs.com/fangts/p/7573818.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值