DELIMITER $$ DROP PROCEDURE IF EXISTS `test`.`proc_tp` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `proc_tp`(in prex int,in max int) begin declare i INT DEFAULT 0; declare s varchar(500); WHILE (i<10 and prex<max) DO select concat(prex,i) into s; insert into ta (a) values (s); set i=i+1; if(i=10 and prex<max) then set prex=prex+1; set i=0; end if; END WHILE ; end $$ DELIMITER ;
3、分别调用执行存储过程 CALL proc_tp(0,10) 创建A类数据 CALL proc_tp(10,100) 创建B类数据 4、查询结果 SELECT * FROM ta t order by cast(a as signed) asc;