MySQL CURRENT_TIMESTAMP 在创建和更新时
我想定义有 2 个 TIMESTAMP 字段的表,如下所示:
I want to define table which will have 2 TIMESTAMP fields, someting like this:
CREATE TABLE `msgs` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`msg` VARCHAR(256),
`ts_create` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`ts_update` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
如何避免错误:
ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
重点是在表模式中保持 ts_create
和 ts_update
的期望行为.
Point is to keep desired behavior of ts_create
and ts_update
in table schema.
推荐答案
猜这是一篇老帖子,但实际上我猜 mysql 在其最近的版本中支持 2 TIMESTAMP mysql 5.6.25 这就是我现在使用的.
Guess this is a old post but actually i guess mysql supports 2 TIMESTAMP in its recent editions mysql 5.6.25 thats what im using as of now.
相关文章