Skip to content

Instantly share code, notes, and snippets.

@dmdavis
Created May 10, 2012 14:58
Show Gist options
  • Select an option

  • Save dmdavis/2653700 to your computer and use it in GitHub Desktop.

Select an option

Save dmdavis/2653700 to your computer and use it in GitHub Desktop.
Automatic MySql Timestamps
-- Limited to one default TIMESTAMP column per table
-- See http://stackoverflow.com/questions/4489548/why-there-can-be-only-one-timestamp-column-with-current-timestamp-in-default-cla
CREATE TABLE my_table (
-- some columns
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment