Point me a reference what happens if empty string (''
) is assigned to a INT NULL
field.
Does it become NULL
or 0
?
Do all versions (starting from 5) of MySQL do the same?
datatypesMySQLtype conversion
Point me a reference what happens if empty string (''
) is assigned to a INT NULL
field.
Does it become NULL
or 0
?
Do all versions (starting from 5) of MySQL do the same?
Best Answer
It depends on the
sql_mode
you're running as. If the mode isn'tstrict
then you'll get the inserted value to be the same as the coercion to that type,This however is insanity, as you can see..
So we can tell MySQL to try to be less of a joke, and more like a real database, like PostgreSQL
And then,
But this time we get,
For more information see,