How to update all dates in a table

I have a table with 5 million records DATETIME. I want to add a year to all the different dates in the table. Can I do all this with a single request? Sort of:

SELECT DATE_ADD(*, INTERVAL 1 YEAR);

Or in any other way that you would recommend. Thank!

+4
source share
1 answer

This should do what you want:

UPDATE table SET datefield = DATE_ADD(datefield, INTERVAL 1 YEAR);

If you need to update each table in the database, check the answers to this question.

+8
source

All Articles