Home >Database >Mysql Tutorial >Can I Have Both Created and LastUpdated Timestamp Columns in MySQL 4.0?

Can I Have Both Created and LastUpdated Timestamp Columns in MySQL 4.0?

Susan Sarandon
Susan SarandonOriginal
2024-11-13 02:44:02454browse

Can I Have Both Created and LastUpdated Timestamp Columns in MySQL 4.0?

Having Both Created and Last Updated Timestamp Columns in MySQL 4.0

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn