- Column that is automatically set to current time when row is created:
column TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- Column that is is automatically set to current time when row is updated:
column TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
- Column that is automatically set to current time when row is created or updated:
column TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
Complete example:
CREATE TABLE table (
id INTEGER(10) UNSIGNED AUTO_INCREMENT,
last_updated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
created DATETIME DEFAULT NULL,
);
No comments:
Post a Comment