在mysql中插入20w用户数据,想用mysql存储过程,老是成功不了,希望大神帮下
发布网友
发布时间:2022-04-08 09:53
我来回答
共3个回答
热心网友
时间:2022-04-08 11:22
改成这样
DROP PROCEDURE IF EXISTS testIndex;
CREATE PROCEDURE testIndex()
BEGIN
DECLARE columnLength INT(3);
SET columnLength = 200000 ;
DROP TABLE IF EXISTS index1;
CREATE TABLE index1 (id INT, name VARCHAR(255));
REPEAT
INSERT INTO index1 (id, name) VALUES (columnLength, columnLength);
SET columnLength := columnLength - 1;
UNTIL columnLength = 0
END REPEAT;
END;
CALL testIndex();
热心网友
时间:2022-04-08 12:40
DELIMITER //
DROP PROCEDURE IF EXISTS insert_log;
CREATE PROCEDURE insert_log(IN loop_times INT)
BEGIN
DECLARE var INT DEFAULT 1;
WHILE var<loop_times DO
SET var=var+1;
INSERT INTO dede_member (`mtype`,`userid`,`pwd`,`uname`,`sex`,`rank`,`lever`) VALUES('个人',CONCAT('20w_ceshi_',n),'52c69e3a57331081823331c4e69d3f2e',CONCAT('20w_ceshi_',n),'男',10,1);
END WHILE;
END
//
DELIMITER ;
CALL insert_log(200000);
热心网友
时间:2022-04-08 14:15
为什么不用数据导入
参考:http://wenku.baidu.com/link?url=evCDLx4rFYWj7DMne-mswiBv1RWb440GYCdqL93FqseSIqn1j9ZiS8CNlNJQF0lHDEAB5Yc_arW2M9ltbX6b1BC6HDAFWi2vCcOsJ-uDSgm