我想定义具有2个TIMESTAMP字段的表,如下所示:
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
。