Sample Header Ad - 728x90

MySQL 8.0 timestamp CURRENT_TIMESTAMP sets date to '0000-00-00 00:00:00' (was ok in 5.7)

0 votes
1 answer
5048 views
The table T has this field +---------------+--------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+-------------------+-----------------------------+ | updated | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | +---------------+--------------+------+-----+-------------------+-----------------------------+ In MySQL 5.7, doing an update of a record and setting updated=null was automatically setting updated to the current date-time UPDATE T SET ...,updated=null WHERE k=123 ==> +---------------------+ | updated | +---------------------+ | 2022-01-05 22:52:05 | +---------------------+ But doing the same in MySQL 8.0, gives +---------------------+ | updated | +---------------------+ | 0000-00-00 00:00:00 | +---------------------+ How can I fix that, is this a MySQL bug, or a new setting (or a change in behavior)?
Asked by Déjà vu (555 rep)
Jan 6, 2022, 04:23 AM
Last activity: Jul 18, 2022, 12:36 PM