MySQL FAQs
FAQs Categories
Client Server Commands
Database Structure
Table Types or Storage Engines
Indexes
SQL Statements
Table Joins
Funtions and Operators
Tricky Select Queries
Speed Up Queries
Data Back Up
General Questions
Errors
1PLs Company - #1Payday.Loans Agency - Loans online and near me $100-$2500 (Same Day)
Powered by MySQL
 
Home / Data Back Up / Import Data / Question No: 175

How to import data from text file into table with LOAD DATA INFILE statement?

I want to import data from text file into MySQL table. Can you explain, how to import data from text file into table with  LOAD DATA INFILE statement?

Answer No: 175

MySQL LOAD DATA INFILE statement allows to import data into table.  This statement facilitates to import data of several formats like csv data, Microsoft Excel, text file and other delimited text files with wide array of options that make this feature so powerful. Suppose you want to import a text file titled authorlist.txt, which contains the following information:

'1','Kenneth James','kj@example.com','CA'
'2','Ashley Lawis','al@example.com','DC'
'3','Arnold Alister','aa@example.com','OH'

The target table, namely authors, consists of three fields, and they are in the same order (author_id, author_email, author_state) as the information found in authorlist.txt:

LOAD DATA LOCAL INFILE authorlist.txt' INTO TABLE authors 
FIELDS TERMINATED BY ',' ENCLOSED BY '\''
ESCAPED BY '\\' LINES TERMINATED BY '\n';

Related MySQL FAQs to the Above FAQ

How-to-use-mysqlimport-client How to use mysqlimport client?

How-to-use-LOAD-DATA-INFILE-statement How to use LOAD DATA INFILE statement?

How-to-import-data-from-Microsoft-Excel-file-into-table-with-LOAD-DATA-INFILE-statement How to import data from Microsoft Excel file into table with LOAD DATA INFILE statement?

About FAQs: Recently Added FAQs

About MySQL FAQs: Site Map | Bookmark Us | Recommend this Site to Your Friend | Contact Us

Useful Links: Wikipedia.org | Oracle.com | w3schools.com | www.php.net | Github.com

© 2024  www.mysqlfaqs.net
All rights reserved.