mySQL column set to default null but import showing 0000-00-00, Import csv data results is all 0's |
mySQL column set to default null but import showing 0000-00-00, Import csv data results is all 0's |
CharlesEF |
Dec 5 2014, 01:49 AM
Post
#1
|
Programming Fanatic Group: Members Posts: 1,984 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Hi All,
I have a mySQL table with a date column that is set for default null. When I manually enter a record the row will show a null value for that field. But, when I try to load data using the 'LOAD DATA LOCAL INFILE' command the column contains all 0's in a date format. I have tried \N and NULL in the csv file as the mySQL documentation suggests but I still get all 0's. I have even left that column blank but 0's are still inserted. Anyone know how to make a csv file load with an actual null value? Thanks for any and all help, Charles |
CharlesEF |
Dec 6 2014, 12:56 AM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,984 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I found a solution (work around?) for my problem. Nothing the mySQL documentation said should work actually worked so I ended up removing the field altogether. The NULL column was the last field of the csv file and the fields are TAB delimited so removing the trailing TAB character seems to have done the job.
|
Brian Chandler |
Dec 6 2014, 01:12 AM
Post
#3
|
Jocular coder Group: Members Posts: 2,476 Joined: 31-August 06 Member No.: 43 |
SQL is a bit like that. I had a similar problem, in that date values default to 0000-00-00; my workaround is just to delete the value, which seems to set it to a genuine NULL.
Just so you know you are not Alone. |
Lo-Fi Version | Time is now: 21st September 2024 - 07:25 AM |