Reputation: 81
I've been through many of the questions that are similar to mine, but all seem to relate to trying to use a default CURRENT_TIMESTAMP with a DATETIME field.
I am having a problem using a CURRENT_TIMESTAMP default with a TIMESTAMP field which I understand is supposed to be supported.
I am using MySQL 5.6.3 community edition. Here is a partial extract of my table creation code:
CREATE TABLE IF NOT EXISTS `my_table` (
`master_id` INT(10) NOT NULL AUTO_INCREMENT ,
`template_id` INT(10) NULL,
`def_id` INT(10) NOT NULL,
'override` TINYINT(1) NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ...
This errors out:
Invalid default value for 'last_update'
Any ideas why?
Upvotes: 0
Views: 685
Reputation: 81
Found the answer.
Someone (not me) had set the following on the MySQL my.cnf:
explicit_default_for_timestamp = 1
Removing this setting resolved the issue.
Upvotes: 1