zoukankan      html  css  js  c++  java
  • 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(str2);
    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数据库创建随机测试数据

  • 相关阅读:
    PHP
    思科模拟器
    路由器
    服务器
    Windows Server 2008 笔记【瞎写】
    Day1 T3 数列
    java中自定义excel模板并且填充内容
    springMVC接收值list时,超过256出现IndexOutOfBoundsException
    java将日期转换成周几
    两个tomcat配置各自的SSL证书(前后端分离)
  • 原文地址:https://www.cnblogs.com/lijiaman/p/12744086.html
Copyright © 2011-2022 走看看