1.创建测试表
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` bigint(20) NOT NULL,
`address` varchar(255) DEFAULT NULL,
`age` int(11) NOT NULL,
`create_time` datetime DEFAULT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;
2.创建存储过程
CREATE PROCEDURE `add_user_data` ( IN n INT ) BEGIN
DECLARE
i INT DEFAULT 1;
WHILE
INSERT INTO `springboot`.`user`( `address`, `age`, `create_time`, `name`) VALUES ('zhejiang', 20, '2019-08-09 04:48:49', 'BBB');
SET i = i + 1;
END WHILE;
END
3.调用执行插入操作
call add_user_data(10000000)