Home >Database >Mysql Tutorial >How to Import Tab-Delimited Text Data into a MySQL Database Using LOAD DATA INFILE?
Importing data from a text file into a MySQL database can be a straightforward process. To achieve this, you can utilize the LOAD DATA INFILE command.
A scenario commonly encountered is having a tab-delimited text file containing data that needs to be imported into a MySQL table. Suppose you have a file named text_file.txt with the following format:
And a MySQL database named Xml_Date with a table called PerformanceReport that has the necessary fields.
To import the data from the text file into the MySQL table, you can use the following command:
Replace /tmp/mydata.txt with the actual path to the text file.
By default, LOAD DATA INFILE assumes that the data is tab-delimited and has one row per line. Therefore, it will read and import the data from the text file directly into the PerformanceReport table.
Note that it is important to ensure that the fields in the text file match the columns in the PerformanceReport table. Otherwise, data loss or incorrect data insertion may occur.
The above is the detailed content of How to Import Tab-Delimited Text Data into a MySQL Database Using LOAD DATA INFILE?. For more information, please follow other related articles on the PHP Chinese website!