mysql存储过程批量插入数据

码农专业户 2011-12-04

mysql> Delimiter ;//
mysql> CREATE PROCEDURE batchInsert1(IN init INT, IN loop_times INT)
     BEGIN
     DECLARE var INT;
     DECLARE userId INT;
     SET var = 0;
     SET userId = init;
     WHILE var < loop_times DO
     INSERT INTO league_ids(userId, level) VALUES(userId, FLOOR( RAND( ) *100 ));
     SET userId = userId + 1;
    SET var = var + 1;
     END WHILE;
     END;//

mysql> call batchInsert1(1, 80000000);
 

相关推荐