如何更新表中的所有日期 [英] How to Update all Dates in a Table
本文介绍了如何更新表中的所有日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含 500 万条 DATETIME
记录的表.我想为表中的所有各种日期时间添加一年.我可以通过一个查询完成所有操作吗?类似的东西:
I have a table with 5 million DATETIME
records. I want to add a year to all the various datetimes in the table. Can I do it all with a single query? Something like:
SELECT DATE_ADD(*, INTERVAL 1 YEAR);
或者您推荐的任何其他方式.谢谢!
Or any other way you would recommend. Thanks!
推荐答案
这应该可以满足您的需求:
This should do what you want:
UPDATE table SET datefield = DATE_ADD(datefield, INTERVAL 1 YEAR);
如果您需要更新数据库中的每个表,请查看这个问题
If you need to update every table in the database check the answers to this question
这篇关于如何更新表中的所有日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文