在MySQL 4.0中同时具有Created和Last Updated timestamp列 [英] Having both a Created and Last Updated timestamp columns in MySQL 4.0
本文介绍了在MySQL 4.0中同时具有Created和Last Updated timestamp列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下表格模式;
CREATE TABLE `db1`.`sms_queue` (
`Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`Message` VARCHAR(160) NOT NULL DEFAULT 'Unknown Message Error',
`CurrentState` VARCHAR(10) NOT NULL DEFAULT 'None',
`Phone` VARCHAR(14) DEFAULT NULL,
`Created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`LastUpdated` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
`TriesLeft` tinyint NOT NULL DEFAULT 3,
PRIMARY KEY (`Id`)
)
ENGINE = InnoDB;
它失败并出现以下错误:
It fails with the following error:
ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause.
我的问题是,我可以同时拥有这两个字段吗?还是我必须在每次交易期间手动设置LastUpdated字段?
My question is, can I have both of those fields? or do I have to manually set a LastUpdated field during each transaction?
推荐答案
查看全文