MySql 大批量导入数据时关闭索引
1.建表
create table goods(
id int primary key,
name varchar(20),
key(name)
)ENGINE=MyISAM DEFAULT CHARSET=utf8;
2.插入数据
delimiter $$
create procedure p1(in num int)
begin
declare name varchar(20) default '';
declare i int default 0;
while i<= num do
set name = concat('April',i);
insert into goods values(i,name);
set i = i+1;
end while;
end $$
delimiter ;
向goods表中插入1百万条数据。直接插入
mysql>call p1(1000000);
Query OK, 1 row affected (2 min 3.33 sec)
先关
共有 0 条评论