mysql 快速生成百万条测试数据
创建内存表及普通表
CREATE TABLE `phone_memory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) NOT NULL,
`tel` varchar(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `phone` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) NOT NULL,
`tel` varchar(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
存储过程
CREATE PROCEDURE `add_tel_memory`(IN n int)
BEGIN
DECLARE i INT DEFAULT 1;
WHILE (i <= n ) DO
INSERT into phone_memory (name,tel) VALUEs ('张三'+i,'18818881888' );
set i=i+1;
END WHILE;
END
调用存储过程
CALL add_tel_memory(1000000)
插入普通表中
INSERT into vote_record SELECT * from phone_memory