使用 WHERE 子句将表的列从备份数据库复制到主数据库
我不小心从数据库中删除了一些行。但我已经有每日数据库备份。
如何从备份数据库中仅恢复已删除的记录?
提前致谢
I accidentally deleted some rows from the database. But I already have daily database backups.
How can I restore only deleted records from the backup database?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有说数据库服务器,所以我不能确定这是否有效,但我相信 MSSQL 上的语法是:
我强烈建议首先在测试数据库上运行,以确保它具有您想要的结果。当然,您需要一个有权访问这两个数据库的用户,并且取决于您是否定义了可能需要很长时间才能在 400k 行上运行的触发器等。
You didn't say a database server, so I can't be sure this will work, but I believe the syntax on MSSQL would be:
I highly recommend running on a test database first to make sure it has the results you want. You will of course need a user who has access to both databases and depending on whether you have triggers etc defined that may take a long time to run on 400k rows.
我认为您在同一台服务器上恢复了数据库,在这种情况下,假设所有以前的数据都是正确的,您可以,尽管您会覆盖自错误以来对血型所做的任何更新。
我建议您在进一步操作之前也备份“不正确”的数据库,以便可以纠正其他错误 - 轻松撤消,这样您至少可以返回到最初的“错误”状态,而不是使问题复杂化。
I take it you have a restore of the database on the same server, in which case assuming all the previous data was correct you could, although you would overwrite any updates to the blood type that have been made since your error.
I would suggest you also backup your 'incorrect' database before you go any further, so that an additional mistakes can be rectified - undone easily so you can at least return to the initial 'error' state instead of compounding problems.