The default behavior of timestamp before MySQL 5.6.6:
Timestamp column if the null attribute is not explicitly declared, the default is not NULL. (Other data types, if not declared as NOT NULL, allow null values.) Sets the timestamp column value to null and is automatically stored as the current timestamp.
The first TIMESTAMP column in the table, if no null property, default, or on update is declared, the DEFAULT current_timestamp and on Update Current_timestamp properties are automatically assigned.
The second timestamp column in the table, which is automatically assigned ' 0000-00-00 00:00:00′ if it is not declared null or the default clause. Inserting a row does not indicate the value of the Change column, which is assigned the ' 0000-00-00 00:00:00′ by default and has no warning.
2 column timestamp default behavior that is not declared null
The method for starting this default setting from MySQL5.6.6 is discarded. The following warning appears when MySQL starts:
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Use the--explicit_defaults_for_timestamp server Option
(seedocumentation for more details).
Turn off warnings and add in my.cnf
[Mysqld]
Explicit_defaults_for_timestamp=true
After restarting MySQL, the error disappears, then timestamp's behavior is as follows:
Timestamp if the declaration not NULL is not displayed and is a null value, you can set the column to NULL instead of the default fill behavior.
The default Current_timestamp and on UPDATE current_timestamp properties are not assigned by TIMESTAMP.
TIMESTAMP is not set to NULL
A timestamp column that is declared NOT NULL and has no default clause is not a default value. When you insert a column into a datasheet without assigning a value to the timestamp column, if you are in strict SQL mode, an error is thrown, and if the strict SQL mode is not enabled, the column is assigned a value of ' 0000-00-00 00:00:00′ and a warning appears. (This is the same as MySQL processing other time type data, such as DateTime)
TIMESTAMP default set to not NULL
Note:
The above content is independent of the storage engine selection.