Initialization and update of datetime type representing datetime at the current time

This section describes the settings for initializing and updating the datetime type, which represents the date and time, at the current time. Available in MariaDB 10 and above (probably).

If you specify "default current_timestamp", you can initialize at the time when the line was created.

If you specify "on update current_timestamp", you can update at the time when the line was updated.

create table (
   created_at datetime not null default current_timestamp,
   updated_at datetime not null default current_timestamp on update current_timestamp

Associated Information