Mysql data type TIMESTAMP usage in mysql database, timestamp data type is a special data type, you can automatically update the record timestamp as long as it is updated without using program updates.
Generally, the table has a Create date field, and other databases have default options. MySQL also has the default value timestamp. However, in MySQL, the value of timestamp is updated even if it is inserted or modified!
In this way, it is not the creation date. it is better to use it as an update date!
Therefore, to record the creation date in MySQL, you must use datetime and then use the NOW () function!
1: If the DEFAULT CURRENT_TIMESTAMP and on update CURRENT_TIMESTAMP clauses are available at the time of definition, the column value is the current timestamp by DEFAULT and is automatically updated.
2: If the DEFAULT or on update clause is not used, it is equivalent to DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP.
3: If only the DEFAULT CURRENT_TIMESTAMP clause is used and the on update clause is not used, the column value is the current timestamp by DEFAULT, but is not automatically updated.
4: If the DEFAULT clause is not used, but the on update CURRENT_TIMESTAMP clause exists, the column defaults to 0 and is automatically updated. (Www.jbxue.com)
5: If there is a constant value DEFAULT, this column will have a DEFAULT value and will not be automatically initialized as the current timestamp. If the column has an on update CURRENT_TIMESTAMP clause, the timestamp is automatically updated. Otherwise, the column has a default constant but will not be updated automatically.
You can use the current timestamp to Initialize values and automatically update values, or either of them. (For example, you can specify automatic update during definition, but it is not initialized .)