timestamp during csv import

mzavarin's profile image mzavarin posted 1 month ago in General Permalink

Hi all, I have a column that is an timestamp. However, when I import a csv with a blank time cell, I just get a bunch of zeros rather than a timestamp based on the time I import the data.

I there a setting that can fix this? my default is current_timestamp so I expected it to auto-fill in the same was as when I update info for a particular row of data.

thanks! mav

ansgar's profile image ansgar posted 1 month ago Permalink

when I import a csv with a blank time cell, I just get a bunch of zeros

Insert NULL in a timestamp column with default current_timestamp - that should do what you except.

Your file needs to have "\N" so the LOAD DATA INFILE detects them as NULL. That's what the MySQL documentation says:

When reading data with LOAD DATA, empty or missing columns are updated with ''. To load a NULL value into a column, use \N in the data file. The literal word NULL may also be used under some circumstances.

Please login to leave a reply, or register at first.