Home > Database > Mysql Tutorial > How to Perform Bulk Inserts in MySQL?

How to Perform Bulk Inserts in MySQL?

Mary-Kate Olsen
Release: 2024-11-11 19:52:03
Original
304 people have browsed it

How to Perform Bulk Inserts in MySQL?

BULK INSERT in MySQL

Similar to the BULK INSERT command in MS SQL, MySQL provides the LOAD DATA INFILE command to perform bulk insertion operations.

Equivalent MySQL Command for BULK INSERT:

LOAD DATA INFILE
Copy after login

Syntax:

LOAD DATA INFILE 'filepath'
INTO TABLE database_name.table_name
FIELDS TERMINATED BY ','
Copy after login

Explanation:

  • filepath: The absolute or relative path of the text file containing the data to be inserted.
  • database_name.table_name: The full table name where the data will be inserted.
  • FIELDS TERMINATED BY ',': Specifies the character used as the field separator in the text file.

Example:

To load data from a text file named MyTextFile.txt into a table named MyTable in the database myDatabase, use the following command:

LOAD DATA INFILE 'C:\MyTextFile.txt'
INTO TABLE myDatabase.MyTable
FIELDS TERMINATED BY ','
Copy after login

The above is the detailed content of How to Perform Bulk Inserts in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template