Use the following command to import name_of_file.csv into the table called name_of_table. (This command assumes the CSV-file values are surrounded by double-quotes (") and seperated by commas (,)
LOAD DATA LOCAL INFILE "name_of_file.csv" INTO TABLE name_of_table FIELDS TERMINATED BY "," ENCLOSED BY "\""
Actually, the above command can be generalized into a command that can parse any kind of file where the values are enclosed and seperated by various characters, and the records are one-to-a-line.
LOAD DATA LOCAL INFILE "name_of_file.file_extension" INTO TABLE name_of_table FIELDS TERMINATED BY "character_to_terminate_fields_with" ENCLOSED BY "character_to_enclose_fields_with"Last updated on 2002-12-27 14:00:00 -0700, by Shalom Craimer
Back to Tech Journal