DROP PROCEDURE IF EXISTS test;
CREATE PROCEDURE test()
BEGIN
DECLARE i INT;
SET i = 0;
REPEAT
INSERT INTO test VALUES(i+11,'test','20'); # 往test表添加数据
SET i = i + 1; # 循环一次,i加一
UNTIL i > 10 END REPEAT; # 结束循环的条件: 当i大于10时跳出repeat循环
SELECT * FROM test;
END
//
CALL test();
DELIMITER ;