码迷,mamicode.com
首页 > 数据库 > 详细

MySQL数据库创建随机测试数据

时间:2020-04-24 12:59:39      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:show   RoCE   pad   sch   test   variable   https   res   def   

原文:MySQL数据库创建随机测试数据

(1)创建测试表

技术图片
create table test01
(
id1 int not null auto_increment,
name varchar(30),
primary key(id1)
);

create table test02
(
id2 int not null auto_increment,
name varchar(30),
primary key(id2)
);
技术图片

 

(2)创建存储过程

技术图片
CREATE DEFINER=`root`@`%` PROCEDURE `p_insert`()
BEGIN
#Routine body goes here...
DECLARE str1 varchar(30);
DECLARE str2 varchar(30);
DECLARE i int;
set i = 0;

while i < 10000 do
set str1 = substring(md5(rand()),1,25);
insert into test01(name) values(str1);
set str2 = substring(md5(rand()),1,25);
insert into test02(name) values(str1);
set i = i + 1;
end while;
END
技术图片

 

(3)制定定时事件

use lijiamandb;
create event if not exists e_insert
on schedule every 10 second
on completion preserve
do call p_insert();

 


(4)手动开始event

技术图片
mysql> show variables like %event_scheduler%;
+----------------------------------------------------------+-------+
| Variable_name | Value |
+----------------------------------------------------------+-------+
| event_scheduler | OFF |
+----------------------------------------------------------+-------+

mysql> set global event_scheduler = on;
Query OK, 0 rows affected (0.08 sec)
技术图片

 

 

 

相关文档集合:

1.MySQL数据库创建随机测试数据
2.Oracle数据库创建随机测试数据

MySQL数据库创建随机测试数据

标签:show   RoCE   pad   sch   test   variable   https   res   def   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12766669.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!