Recently I faced a new problem in MySQL. I was about to create a new table with
col1 TIMESTAMP DEFAULT NULL
(i.e. the column having the default NULL value), but on creation that gave me an error:
Invalid default value for column
But when I tried col1 TIMESTAMP NULL DEFAULT NULL, that table got created.
I want to know what is the difference between the above two syntaxes. I also faced this issue earlier too in some insert NULL values in column.
Can any one explain the cause of this problem, like is it a version specific issue or something else with MySQL?
col1 timestamp null, thedefault nullcan be omitted (at least according to the documentation). A non-nullable timestamp column has predefined special properties, but they are suppressed when you explicitly make the column nullable.