Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of batch data input in mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the mysql batch data entry method, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

Mysql batch input data methods: 1, the use of circular insertion; 2, reduce connection resources, splice a sql;3, use stored procedures; 4, use [MYSQL LOCAL_INFILE].

The method of batch inputting data in mysql:

Method 1: circular insertion

This is also the most common way, if the amount of data is not very large, you can use it, but you have to consume the resources to connect to the database every time.

The general thinking is as follows

(I write pseudo code here, which can be written in combination with my own business logic or framework syntax.)

For ($itim1bot / value) {$sql = 'insert.'; / / querysql} while ($I exec ($sql); if (! $res) {/ / TODO insert failure} @ unlink ($my_file);}}

Again, each piece of data is very large, with a lot of varchar4000 and text fields.

It takes 2.160s

The above meet the basic needs, 1 million data is not a big problem, or the data is too large also involves sub-database sub-table, or the use of queue insertion.

Thank you for reading this article carefully. I hope the article "mysql bulk data entry method" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report