mysql version is 5.7.20
create table test (
start_day timestamp,
create_time timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
this sql can execute well.
create table test (
start_day timestamp,
create_time timestamp,
update_time timestamp
);
Otherwise, this sql shows 1067 - Invalid default value for 'create_time'. In first sql, I found that the default value for start_day is CURRENT_TIMESTAMP, and it will update automatically. Can someone explain what is the default value in the second sql and what is the difference between the two sql.