I load a CSV
file using LOAD DATA LOCAL INFILE
. Some values eg for decimals
are optional and thus not set in csv.
I tried both inserting a blank ,,
in csv, and a ,null,
. For both of them the mysql
table shows a 0
as decimal value.
CREATE TABLE `my_table` (
...
`price` decimal(10,2) DEFAULT NULL,
)
But why isn't the default value used if I leave the field blank during load?
Sidenote: the linked question is not an answer, as the comment accepted has nothing to do with the special null handling in mysql! Moreover, an acceptable answer to that question should state the solution as a oneliner, so everyone finds a quick solution. Which is also not the case in the linked "duplciate" question.