首页 >数据库 >mysql教程 >MySQL 存储过程循环插入数据_MySQL

MySQL 存储过程循环插入数据_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-01 13:43:441216浏览

bitsCN.com 测试机器时经常要测试inset 和alert 的绝对值,所以写了个存储过程来完成.
 

DROP PROCEDURE IF EXISTS proc_buildata; 
tudou@Gyyx 
CREATE PROCEDURE proc_buildata(IN loop_times INT) 
BEGIN 
DECLARE var INT DEFAULT 0; 
 
PREPARE MSQL FROM 'CREATE TABLE IF NOT EXISTS `employee` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`employeeid` int(10) unsigned NOT NULL COMMENT ''0'',`employeename` varchar(64) NOT NULL DEFAULT '''',PRIMARY KEY (`id`)) ENGINE=InnoDB';   
EXECUTE MSQL; 
 
WHILE varSET var=var+1; 
INSERT INTO employee (employeeid,employeename) VALUES (var,CONCAT('test',var)); 
 
END WHILE; 
END 
 
CALL proc_buildata(2000000); 
 
 
SELECT COUNT(1) FROM employee;

摘自 ylqmf的专栏 bitsCN.com

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn