Reputation: 199
I'm trying to import a CSV file into a MySQL 5.1 DB using phpMyAdmin. The file includes several date columns which may contain NULL
values. According to the manual, NULL
should be written as \N
. However, after an otherwise successful import, \N
appears as 0000-00-00
in the date columns (as opposed to NULL
). How do I get NULLs imported?
Options set:
,
"
,\
,auto
.Upvotes: 2
Views: 4788
Reputation: 199
phpMyAdmin distinguishes two CSV import formats: CSV
and CSV with LOAD DATA
. The latter option actually accepts \N
as described in the manual.
If columns are enclosed by a character (as it is the case), NULLs may also be imported using the former method (no LOAD DATA
) by setting a value to a non-enclosed NULL
in the CSV file. This is in accordance with the manual's following statement:
If FIELDS ENCLOSED BY is not empty, a field containing the literal word NULL as its value is read as a NULL value. This differs from the word NULL enclosed within FIELDS ENCLOSED BY characters, which is read as the string 'NULL'.
Upvotes: 5