I’m importing data from a file ‘infile.txt’ and I’m using the table: People (ID is auto_incremented) to insert it into
ID DATE NAME
infile.txt
Ben
Jim
Jack
I’m using this method
LOAD DATA INFILE '~/infile.txt'
INTO TABLE People
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(DATE, NAME);
Desired output
ID DATE NAME
1 2012-03-06 15:13:40 Ben
2 2012-03-06 15:13:41 Jim
3 2012-03-06 15:13:42 Jack
To set your
DATEfield as a timestamp:The
DATEfield will automatically contain the time that the record was inserted, so you just ignore that field in your load. AlsoDATEisn’t a good choice for a field name, as it’s a reserved word that should be enclosed in backticks.