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;