Skip to content

Instantly share code, notes, and snippets.

@dr-skot
Created March 14, 2023 16:29
Show Gist options
  • Save dr-skot/535572b05d08b71e419853849fd81fde to your computer and use it in GitHub Desktop.
Save dr-skot/535572b05d08b71e419853849fd81fde to your computer and use it in GitHub Desktop.
MySQL CREATE TABLE syntax for automatic creation-time and modification-time columns
CREATE TABLE `database-name`.`table-name`(
...
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE = InnoDB;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment