向mysql数据库下的某个表中插入大量数据

使用的方法:

DELIMITER $$
USE `macross_wudi`$$
DROP PROCEDURE IF EXISTS `test`$$
CREATE PROCEDURE `test`()
 BEGIN
    DECLARE i INT DEFAULT 333;
    DECLARE j INT DEFAULT 333;
    WHILE (i <= 800000) DO
        REPLACE  INTO fs_mobile_ms_dat VALUES(i,669,j,'guest','running','2012-10-10 16:06','2012-10-11 16:06','0','0');
        SET i = i + 1;   
        SET j = j + 1;
    END WHILE;
 END$$
DELIMITER ;
CALL test();

 

借鉴的方法:

DROP PROCEDURE test;
DELIMITER;
CREATE PROCEDURE test()
BEGIN
DECLARE i INT DEFAULT 1;
DECLARE j INT DEFAULT 1;
DECLARE k INT DEFAULT 1;
DECLARE s INT DEFAULT 1;
WHILE i<=500000
DO
WHILE j<=50
DO
insert into fs_ms_task values(k,i,j,'guest','running','2012-08-24 16:06','2012-08-24 16:06','0','0');
SET j = j+1;
SET k = k+1;
END WHILE;
SET i=i+1;
SET j = 1;
END WHILE;
END;
CALL test();

     

你可能感兴趣的:(工作相关)