Why won't MySQL let me remove attribute “on update CURRENT_TIMESTAMP”?

匆匆过客 提交于 2019-12-05 00:15:26

You should specify DEFAULT CURRENT_TIMESTAMP (or DEFAULT 0)

ALTER TABLE pages CHANGE date_created date_created TIMESTAMP NOT NULL DEFAULT 0,
CHANGE  `date_updated`  `date_updated` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL

As of MySQL version 5.6.6, you can use the explicit_defaults_for_timestamp option in the configuration file, therefore timestamp columns will not have 'DEFAULT CURRENT_TIMESTAMP' or 'ON UPDATE CURRENT_TIMESTAMP' attributes by default. It will also be possible so set these columns to NULL if they are not declared as NOT NULL.

See: http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!