MySQL更新 - 如何延迟更新?

时间:2016-09-09 17:50:32

标签: mysql

如何延迟表中每一行的更新?

例如我有10行,如果我运行它:

UPDATE article SET created_on=unix_timestamp(now()), updated_on=unix_timestamp(now());

这10行将具有相同的时间戳。如何通过循环和延迟更新来在每一行上设置不同的时间戳?

有什么想法吗?

SQL:

CREATE TABLE IF NOT EXISTS `article` (
  `article_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `type` VARCHAR(255) NOT NULL COMMENT 'page, post',
  `url` VARCHAR(255) NOT NULL,
  `title` VARCHAR(255) NOT NULL,
  `content` LONGTEXT NULL DEFAULT NULL,
  `backdated_on` INT UNSIGNED NULL DEFAULT NULL COMMENT 'The manual datetime that is modified or input by the user.',
  `created_on` INT UNSIGNED NOT NULL COMMENT 'The permanent datetime when the article is created.',
  `updated_on` INT UNSIGNED NOT NULL COMMENT 'The datetime when the article is updated on.',
  PRIMARY KEY (`article_id`),
  UNIQUE INDEX `url_UNIQUE` (`url` ASC))
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8
COMMENT = 'Entity that holds the article with one-to-one properties.'
INSERT_METHOD = NO
KEY_BLOCK_SIZE = 1;

0 个答案:

没有答案