測試機器時經常要測試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 var<loop_times DO
SET 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的專欄