今天导入公司的sql脚本时,报了一个错,本地可以,测试环境就是运行报错
错误截图:
1293错误
谷歌了好久,才知道原因,原来是版本不一致的问题,一个是5.5 一个是5.7
5.5版本官方的说明是:One TIMESTAMP column in a table can have the current timestamp as the default value for initializing the column, as the auto-update value, or both. It is not possible to have the current timestamp be the default value for one column and the auto-update value for another column.
5.7版本官方文档的说明:Previously, at most one TIMESTAMP column per table could be automatically initialized or updated to the current date and time. This restriction has been lifted. Any TIMESTAMP column definition can have any combination of DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses. In addition, these clauses now can be used with DATETIME column definitions. For more information, see Automatic Initialization and Updating for TIMESTAMP and DATETIME.
统一sql版本或使用触发器可以解决。