第一步:创建表
drop table Student;
create table Student(
id int NOT NULL AUTO_INCREMENT,
name varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
drop PROCEDURE repeatStudent; -- 删除存储过程
-- 创建存储过程
DELIMITER CREATE PROCEDURE repeatStudent()
BEGIN
DECLARE num INT;
SET num = 1;
WHILE num < 30 DO
INSERT INTO `Student` (`name`)
values(CONCAT('张三', num));
SET num = num + 1;
END WHILE;
END -- 结束
CALL repeatStudent(); -- 执行存储过程
select * from Student