创建和更新时的MySQL CURRENT_TIMESTAMP [英] MySQL CURRENT_TIMESTAMP on create and on update
本文介绍了创建和更新时的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在其最新版本mysql 5.6.25中支持2 TIMESTAMP,这就是我目前使用的时间.
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.
这篇关于创建和更新时的MySQL CURRENT_TIMESTAMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文