mysql-error-1293

Timestamp for row creation and last modification

血红的双手。 提交于 2019-12-10 12:57:09
问题 I need to keep track of the time a row was inserted into the database, and the time it was last modified. I tried to create two separate columns, and use CURRENT_TIMESTAMP : create table def ( id int, creation timestamp default CURRENT_TIMESTAMP, modification timestamp on update CURRENT_TIMESTAMP ); However, this produced an error: ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause What is the best way

Why won't MySQL let me remove attribute “on update CURRENT_TIMESTAMP”?

匆匆过客 提交于 2019-12-05 00:15:26
I have a table with two timestamp fields. I simply defined them with a name and the type TIMESTAMP , yet for some reason MySQL automatically set one of them with a default value and the attribute on update CURRENT_TIMESTAMP . I was planning on having NO default value in either of the fields, but one of the fields is called "date_updated" so I suppose I could set the mentioned attribute to that field. Unfortunately, it's the field "date_created" that was set with the on update CURRENT_TIMESTAMP attribute, and no matter what I do, MySQL won't let me remove it. I've tried editing the "date

MySQL CURRENT_TIMESTAMP on create and on update

纵饮孤独 提交于 2019-11-27 06:35:35
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 ) How to do this avoiding error: ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause Point is to keep desired behavior of ts_create and ts_update in table schema. This is a limitation of mySQL, you cannot have two TIMESTAMP

Having both a Created and Last Updated timestamp columns in MySQL 4.0

烂漫一生 提交于 2019-11-26 19:19:44
I have the following table schema; 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

MySQL CURRENT_TIMESTAMP on create and on update

馋奶兔 提交于 2019-11-26 17:35:46
问题 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 ) How to do this avoiding error: ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause Point is to keep desired behavior of ts

Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT clause?

不问归期 提交于 2019-11-26 14:08:10
Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause? CREATE TABLE `foo` ( `ProductID` INT(10) UNSIGNED NOT NULL, `AddedDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `UpdatedDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=INNODB; The error that results: Error Code : 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause This limitation, which was only due to historical, code legacy reasons, has been lifted in recent versions of MySQL:

Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT clause?

守給你的承諾、 提交于 2019-11-26 08:51:31
问题 Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause? CREATE TABLE `foo` ( `ProductID` INT(10) UNSIGNED NOT NULL, `AddedDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `UpdatedDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=INNODB; The error that results: Error Code : 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause 回答1: This

Having both a Created and Last Updated timestamp columns in MySQL 4.0

主宰稳场 提交于 2019-11-26 06:55:00
问题 I have the following table schema; 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