

Sometimes the first row of a data text file will contain column headings. The statement would need to be entered like this: Suppose also that the fields are terminated with a.
Mysql import data from csv windows#
However, suppose that the rows in the text file start and end with double-quotes and a Windows hard-return (i.e., a return and a line-feed). If lines are terminated by a line-feed ( \n), it doesn't need to be specified since it's the default.

The third line above specifies the vertical bar as the field delimiter.įor some text files, you may need to specify the line terminator. The INTO TABLE clause specifies the database and the table to import into. For a Windows server, the forward-slashes are still used for the file's path, but a drive may need to be specified at the beginning of the path (e.g, 'c:/tmp/prospects.txt'). The first line of this statement specifies the path and the name of the file to import. Below is what you might enter through the mysql client to import the data into the table table1 Suppose further that within the file there is one record per line and that the fields of each are separated by a vertical bar. As an example, suppose that you have a text file called data.txt in the /tmp directory. If you have a plain text file that contains data, the LOAD DATA INFILE statement can be used to import it into MySQL. How do I import data into MySQL from a simple text file?.
