MySQL 存储过程循环插入数据_MySQL
程序员文章站
2022-05-22 14:10:39
...
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 var 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的专栏 bitsCN.com
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
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
推荐阅读
-
关于mysql一次自动插入2条数据出现的原因,和求解决办法
-
怎么现在写MYSQL数据库 都在用存储过程了。ecshop phpcms等等 这些好像都没有用给
-
读书笔记-MySQL存储过程-存储函数_MySQL
-
MySQL简略存储过程示例(持续追加)
-
mysql中百万级数据插入速度测试
-
PHP连接MySQL数据库过程
-
mysql从某表中查询数据插入到另一表的处理_MySQL
-
mysql-MySQL:为什么这样的小改动会造成存储过程错误呢?
-
mysql-请问:用java代码把不同的excel形式加载到MySQL数据库中(循环判断空就停止)?谢谢!
-
在编写存储过程时使用 Set NoCount On_MySQL