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 inserting data in batch with insert statement in mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail the method of inserting data in bulk with insert statements in mysql. The content of the article is of high quality, so I will share it for your reference. I hope you can get something after reading this article.

The INSERT INTO statement is used to insert new records into the table. INSERT INTO statements can be written in two forms.

In the first form, you do not need to specify the name of the column in which you want to insert data, just provide the value to be inserted:

INSERT INTO table_name

VALUES (value1,value2,value3,...)

The second form requires you to specify the column name and the value to be inserted:

INSERT INTO table_name (column1,column2,column3,...)

VALUES (value1,value2,value3,...)

A common insert statement inserts only one piece of data into a database:

Insert into persons (id_p, lastname, firstName, city) values (204 deng', 'shenzhen')

(as above, only one record is inserted)

How to insert multiple records at a time by insert

Examples of use:

Insert into persons (id_p, lastname, firstName, city) values (200Japanese ', 'deng',' shenzhen'), (2011Z2', 'deng',' GD'), (202 'deng',' Beijing')

In this way, you can insert data in batches, and follow this syntax, you can insert data in batches.

Successful execution. Screenshot:

It is said that in program development, inserting multiple pieces of data at a time is much more efficient than inserting data one at a time.

Therefore, when developing the program, it is also quite good to use this batch insert.

This statement is executed on MySQL 5, postgreSQL 9.3.

The above is the method of inserting data in bulk with insert statement in mysql. Is there anything to gain after reading it? If you want to know more about it, you are welcome to follow the industry information. Thank you for reading.

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