1. Examples
CREATE TABLE `job` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`status` varchar(15) DEFAULT NULL COMMENT 'Status 1: In progress 2 Completed 3 Failed',
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
`update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'modify time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2. Explanation
During the insert operation, if there is a timestamp field, the property is set to current_ Time stamp, the current system time is inserted regardless of whether the field has a set value
During the update operation, if a timestamp field property is set to ON UPDATE CURRENT_ When the data is updated, this field will automatically update the time
Note: these two properties can be used in combination