Home >Database >Mysql Tutorial >mysql使用存储过程制造测试数据_MySQL

mysql使用存储过程制造测试数据_MySQL

WBOY
WBOYOriginal
2016-06-01 13:34:261001browse

bitsCN.com

mysql使用存储过程制造测试数据

 

[sql] 

DELIMITER $$  

DROP PROCEDURE IF EXISTS message_insert_procedure;  

CREATE PROCEDURE `test`.`message_insert_procedure` ( loop_times INT)  

BEGIN  

    DECLARE var INT DEFAULT 0;    

    WHILE var

    SET var=var+1;    

    INSERT INTO test.message (msg_id,content,type,creator_id,create_time)   

    VALUES (var,CONCAT(var,' - ','粽子--五月端午是我生辰到,身穿着一领绿罗袄,小脚儿裹得尖尖娇。解开香罗带,剥得赤条条。插上一根销儿也,把奴浑身上下来咬。'),0,10013,now());    

    END WHILE;     

END  

 

上面是代码:

 

说明:test是我的数据库,message是我的表,还有,今天心情一点都不好.

 

调用的时候请用下面:

 

[html] 

use test;  

delete from message;  

call message_insert_procedure(10000000);  

 中间的一句 delete from message ; 如果你用的是workbench这类的软件,这句话是报错的,请在workbench的performance的sql queries 选项内,把 General子项下面的 "Safe Updates" 钩掉 , 然后 reconnect 一下就完事了.

数据测试:Ubuntu 12.10 下mysql ,数据测是1000W条 548秒.
 

bitsCN.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn