Search code examples
mysqlimportload-data-infile

(SQL) How to set column names of MySQL table as the delimited first line of my infile?


The first line of my infile is actually the name of the columns delimited in the file. Is there anyway for a mysql import to use those column names in the file, and create columns in the mysql table with those names so that I don't have to?


Solution

  • I don't think you can import structure using LOAD DATA INFILE if that's what you mean, but it shouldn't be that hard to write a parser to read that line and create a table in a general purpose language, and then you can use IGNORE 1 LINES in the LOAD statement to ignore the structure definition line on import.