DROP PROCEDURE IF EXISTS test; CREATE PROCEDURE test() #创建存储函数; BEGIN DECLARE i INT DEFAULT 1; WHILE i < 20 DO INSERT INTO `t_test_auto`(`id`, `name`,`age`) VALUES ('1'+i,'haha',ROUND((7+RAND()*6),2)); SET i = i+1; end WHILE; END; CALL test();#调用存储函数