一、建表语句
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for user_info
-- ----------------------------
DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`age` int(0) NULL DEFAULT NULL,
`gender` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`address` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tel` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
二、存储过程
-- 如果存在同名存储过程则删除.
DROP PROCEDURE IF EXISTS my_insert;
-- 创建存储过程
CREATE PROCEDURE my_insert()
BEGIN
DECLARE n int DEFAULT 0;
loopname:LOOP
INSERT INTO user_info(name,age,gender,address,tel)VALUES('abc',23,'男','中国',18712341234);
SET n=n+1;
IF n=100000 THEN
LEAVE loopname;
END IF;
END LOOP loopname;
END;
-- 执行存储过程
CALL my_insert();