Importing CSV data into a MySQL table can be achieved without the use of a GUI by utilizing the LOAD DATA syntax.
Syntax with First Row as Column Names:
To establish the first row of data as column names, execute the following code:
LOAD DATA LOCAL INFILE 'uniq.csv' INTO TABLE tblUniq FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES (uniqName, uniqCity, uniqComments)
This assumes:
Explanation:
The above is the detailed content of How Can I Import a CSV File into MySQL Using the LOAD DATA INFILE Command?. For more information, please follow other related articles on the PHP Chinese website!