sql - MySQL load data infile ("NULL" String in CSV for datetime) -


hi have following csv format

id   (tab)  creation_date ------------------------- 1           2012-05-04 15:26:45.000 2           null 

for importing using:

load data local infile './test.csv' table test fields terminated '\t'   lines terminated '\n'   ignore 1 lines     (id,@creation_date)   set     creation_date = nullif(@creation_date,'null'); 

but unfortunately null value (string) not interpreted , set null in column. instead warning data truncation , default date inserted 0000-00-00....

how can check: string = "null" insert null column?

you can use "trailing nullcols" insert null values file database.

ex:

load data infile 'test1.csv' append table tab1 trailing nullcols (  id integer <data type> terminated ',', creation_date <data type>  ) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -