1

I am trying to insert data into a mysql table from a csv file. I am using the infile sql command, but I am having trouble because the first column of the table is an id that is set as an auto increment field. what do I have to set my first column value to in order to get this to work, or can I do it at all?

Thanks

1
  • I actually just ended up removing the autoincrement column, and doing a regular load data. I then was able to add in the auto-increment column afterwords. thanks Commented May 25, 2010 at 18:25

1 Answer 1

1

Try using an empty field or a TAB character as a first column value in a file

(see comment "Posted by Mohamed Abdulla on August 17 2005 11:14am" on http://dev.mysql.com/doc/refman/5.0/en/loading-tables.html)

Another solution:

LOAD DATA INFILE 'DATA.txt' INTO TABLE your_table
FIELDS TERMINATED BY '^'
OPTIONALLY ENCLOSED BY '~'
(column2, column3, ... )
SET column1 = NULL 
Sign up to request clarification or add additional context in comments.

1 Comment

The SET clause is optional here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.