The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> mySQL column set to default null but import showing 0000-00-00, Import csv data results is all 0's
CharlesEF
post Dec 5 2014, 01:49 AM
Post #1


Programming Fanatic
********

Group: Members
Posts: 1,981
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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Dec 6 2014, 12:56 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Dec 6 2014, 01:12 AM
Post #3


Jocular coder
********

Group: Members
Posts: 2,460
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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 16th April 2024 - 12:52 AM