Hello SitePoint Forum!
Question: What is the proper default value for VARCHAR in a MySQL database table?
The MySQL Manual seems to say the default value should be NULL for a VARCHAR column type.
The Manual says “If the column can take NULL as a value, the column is defined with an explicit DEFAULT NULL clause.”
http://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html
However, if I set the value to ‘None’ using phpMyAdmin, when I export the table, MySQL has changed the value to a). NOT NULL; and b). has not inserted a default value like an empty string.
I asked a similar question back in 2012 . The answer clarified my question but MySQL column types are still hazy.
Thanks.
r937
November 7, 2016, 6:41pm
2
i’d be happy to expand on the answer i gave you at that time
NULL is not a value – it is the absence of a value
if you specify NOT NULL and then declare a default value like an empty string or a blank, then i submit that what you really want is NULL
r937;
Thanks for responding.
It’s a different project than in 2012 but a similar topic.
I have got a new cPanel shared hosting. The server is set to strict SQL mode.
The old hosting I think must have not been set to the strict SQL mode. The MySQL seems to be working differently on the cPanel hosting.
I appreciate the help.
Thanks again.
system
Closed
February 7, 2017, 5:37am
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.