Home > Database > Mysql Tutorial > How to Import Tab-Delimited Text Data into a MySQL Database Using LOAD DATA INFILE?

How to Import Tab-Delimited Text Data into a MySQL Database Using LOAD DATA INFILE?

Mary-Kate Olsen
Release: 2024-12-16 16:43:11
Original
641 people have browsed it

How to Import Tab-Delimited Text Data into a MySQL Database Using LOAD DATA INFILE?

Importing Data from Text File to MySQL Database

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!

source:php.cn
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