Search code examples
mysqlcsvtextload

How to specify column names when loading data to mySQL table?


How should I specify the columns names when I want to load a MySQL table from a local .csv file using the LOAD DATA LOCAL FILE command in MySQL?


Solution

  • You specify a comma seperated list of columns, in parentheses, at the end (but before the optional SET parameters).

    See https://dev.mysql.com/doc/refman/8.0/en/load-data.html#load-data-column-list