mysql set time to automatically generate

create table staff
(
  id          int      auto_increment
    primary key,
  name        varchar(32) not null,
  create_time datetime DEFAULT CURRENT_TIMESTAMP,
  update_time datetime ON UPDATE CURRENT_TIMESTAMP,
  status      int         null
)
  engine = InnoDB;

 

create_time will be automatically generated on insert 
update_time will be automatically generated on update

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324737146&siteId=291194637