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

前端 未结 11 2197
逝去的感伤
逝去的感伤 2020-11-27 09:19

I have the following table schema;

CREATE TABLE `db1`.`sms_queue` (
  `Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `Message` VARCHAR(160) NOT NULL DEFAUL         


        
11条回答
  •  猫巷女王i
    2020-11-27 10:09

    This issue seemed to have been resolved in MySQL 5.6. I have noticed this until MySQL 5.5; here is an example code:

    DROP TABLE IF EXISTS `provider_org_group` ;
    CREATE TABLE IF NOT EXISTS `provider_org_group` (
      `id` INT NOT NULL,
      `name` VARCHAR(100) NOT NULL,
      `type` VARCHAR(100) NULL,
      `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `insert_src_ver_id` INT NULL,
      `updated` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,
      `update_src_ver_id` INT NULL,
      `version` INT NULL,
      PRIMARY KEY (`id`),
      UNIQUE INDEX `id_UNIQUE` (`id` ASC),
      UNIQUE INDEX `name_UNIQUE` (`name` ASC))
    ENGINE = InnoDB;
    

    Running this on MySQL 5.5 gives:

    ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
    

    Running this on MySQL 5.6

    0 row(s) affected   0.093 sec
    

提交回复
热议问题