What is the method for inserting data in bulk in MySQL?

In MySQL, you can use the INSERT INTO statement to insert data in bulk. One common method is as follows:

INSERT INTO table_name (column1, column2, column3) VALUES
(value1, value2, value3),
(value4, value5, value6),
(value7, value8, value9);

In the example above, table_name is the name of the table where the data will be inserted, column1, column2, column3 are the names of the columns in the table, and the values to be inserted are specified within the parentheses following the VALUES keyword. Multiple rows of data can be inserted at once.

Moreover, another option is to use the LOAD DATA INFILE statement to bulk insert data. This statement allows for directly importing data from a file into a MySQL table.

广告
Closing in 10 seconds
bannerAds