Create Table 'ts '(
'Ts1' timestamp not null,
'Ts2' timestamp not null default current_timestamp,
'Ts3' timestamp null default null
) Engine = InnoDB default charset = utf8
Error code: 1293
Incorrect table definition; there can be only one timestamp column with current_timestamp in default or on update clause
Execution time: 00: 00: 00: 000
Transfer Time: 00: 00: 00: 000
Total time: 00: 00: 00: 000
Ts1 is the same as ts2 during creation, and only one update is allowed.
Create Table 'ts '(
'Ts2' timestamp not null default current_timestamp,
'Ts3' timestamp null default null
) Engine = InnoDB default charset = utf8
In this way, the updated ts2 will not be automatically updated.
Create Table 'ts '(
'Ts1' timestamp not null,
'Ts3' timestamp null default null
) Engine = InnoDB default charset = utf8
After being inserted, the SQL statement becomes
Create Table 'ts '(
'Ts1' timestamp not null default current_timestamp on update current_timestamp,
'Ts3' timestamp null default null
) Engine = InnoDB default charset = utf8
'Ts1' timestamp not null, => 'ts1' timestamp not null default current_timestamp on update current_timestamp,
At this time, the ts1 field will be automatically updated during the update. If you do not want to update the field, add the default
'Ts2' timestamp not null default current_timestamp,
The default value is 'ts3' timestamp null. default null, not 'ts3' timestamp default null.