Issue:
When creating a MySQL 4.0 table with both Created and LastUpdated TIMESTAMP columns, the following error is encountered:
ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause.
Question:
Is it possible to have both Created and LastUpdated timestamp columns in MySQL 4.0?
Answer:
MySQL 5.5 and Earlier:
No. According to the MySQL 5.5 documentation, only one TIMESTAMP column per table can have the current timestamp as either the default value for initialization or the auto-update value.
MySQL 5.6.5 and Later:
Yes. In MySQL 5.6.5, the restriction on having only one automatically initialized or updated TIMESTAMP column was lifted. Now, any TIMESTAMP column can have a combination of DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses.
The above is the detailed content of Can I Have Both Created and LastUpdated Timestamp Columns in MySQL 4.0?. For more information, please follow other related articles on the PHP Chinese website!