ITPub博客

首页 > Linux操作系统 > Linux操作系统 > mysql的存储过程

mysql的存储过程

原创 Linux操作系统 作者:markzy5201190 时间:2013-02-04 19:45:52 0 删除 编辑
一些测试场景的执行往往需要先往DB中注入一些测试数据,一般可以通过sql脚本来实现

  1. drop procedure if exists init_QB_Static_Info;  
  2.   
  3. delimiter //  
  4. create procedure init_QB_Static_Info ()  
  5. begin  
  6.     declare i int default 0;  
  7.   
  8.     delete from tQuestionBank_Static_Info;  
  9.   
  10.     while(i < 1000) do  
  11.         insert into tQuestionBank_Static_Info values(i, mod(i, 10), CONCAT('Test', i), 'filepath:xxxxxx', i, 10.1, 'Test Question', now(), 0);  
  12.         set i = i + 1;  
  13.     end while;  
  14. end;  
  15.   
  16.   
  17. drop procedure if exists init_QB_Access_Info;  
  18.   
  19. create procedure init_QB_Access_Info ()  
  20. begin  
  21.     declare i int default 0;  
  22.   
  23.     delete from tQuestionBank_Access_Info;  
  24.   
  25.     while(i < 100000) do  
  26.         -- if (mod(i , 2) = 0) then  
  27.             insert into tQuestionBank_Access_Info values(1, mod(i, 1000), mod(i, 10), 1, now());  
  28.         -- end if;  
  29.         set i = i + 1;  
  30.     end while;  
  31. end;  
  32. //  
  33. delimiter ;  

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26855487/viewspace-753914/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-04-05

  • 博文量
    82
  • 访问量
    472458