mysql - 如何批量插入数据库10W条数据
PHPz
PHPz 2017-04-17 15:21:13
0
5
798

sql语句能实现吗

PHPz
PHPz

学习是最好的投资!

reply all(5)
黄舟

Is there any other way besides sql? Generate the sql file and import it directly. 100,000 pieces of data are not too much.

左手右手慢动作

Navicat Import Wizard, you deserve it

伊谢尔伦

Use insert to batch insert, for example:

INSERT INTO test_table (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

But you can’t insert too many items each time. For example, insert 100 items at a time, and then insert 1,000 times in total, which will be 100,000 items, and the speed will not be very slow

大家讲道理

1. SQL statements can definitely be implemented, but inserting so much data will definitely be very slow.
2. It can also be achieved using the client tool SQLyog, just import it.

迷茫

Let me give you what I summarized before:
--Declare a stored procedure (understood as a function)

delimiter ;;
create procedure myproc ()

begin
declare num int ;
set num = 1 ;
while num < 10 do
    insert into user (id, `name`, sex)
values
    ('', concat("name", num), 1) ;
set num = num + 1 ;
end
while ;

end;;

--Execute this function
call myproc();
--View the results of inserting data
select * from user;
--Delete this stored procedure
drop procedure myproc;

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!