我如何...如何回滚上次更新我执行的SQL查询 [英] How Do I...How To Rollback Last Update Sql Query I Did

查看:54
本文介绍了我如何...如何回滚上次更新我执行的SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我来说非常紧急.....



更新ProductSerial set BranchID = 2其中BranchID = 4且ActivatedSystems = 0且CustomerID = 1且ProductID = 19



这是我必须运行的查询.....而不是我做的..



update ProductSerial set BranchID = 2





我的在线数据库.....我必须从前一阶段恢复它....

解决方案

Ow。这是一个很大的哎呀。



就实际的回滚而言,你不能 - 你需要一个未提交的交易才能回滚。



规则1:永远不要在生产数据库上开发或测试。

规则2:始终保持良好的备份。



我猜你自己忽略了规则1,你也忽略了规则2?

除非你有一个好的,最近的备份,你几乎被塞满了 - 你不是很多很容易做到。所以,现在去找你的老板,告诉他发生了什么。无论如何他都会发现,并且在前面可能会有所帮助 - 这肯定比他最后一次寻找猎物并最终找到...



如果你很幸运,您的数据库设置为完全恢复模式,他将能够从事务日志中恢复原始值。但是你留下的时间越长,麻烦就越多,麻烦就越多。


我同意OriginalGriff。



我还建议我找到一些技巧。

1. 如何从没有备份的SQL Server恢复修改过的记录 [ ^ ]

2. 如何从没有备份的意外更新中恢复SQL Server数据 [ ^ ]



我在1年前尝试了第一个并且它有效。



一切顺利。 :)

Its very urgent for me.....

update ProductSerial set BranchID=2 where BranchID=4 and ActivatedSystems=0 and CustomerID=1 and ProductID=19

this is the query i have to run.....instead of that i did..

update ProductSerial set BranchID=2


it my online db.....i have to recover it from previous stage....

解决方案

Ow. That's a big oops.

In terms of actual "rollback" you can't - you need an uncommitted transaction in order to rollback.

Rule 1: Never develop or test on production databases.
Rule 2: Always have good backups.

I'm guessing that since you ignored Rule 1, you have also ignored Rule 2?
Unless you have a good, recent backup, you are pretty much stuffed - there isn't a lot you can easily do. So go to your boss, now, and tell him what has happened. He's going to find out anyway, and being upfront may help - it's certainly better than him going on a witch hunt and finding out in the end...

If you are lucky, your DB is set to full recovery mode and he will be able to restore the original values from the transaction log. But the longer you leave it the more trouble that is, and the more hassle that is going to cause.


I agree with OriginalGriff.

I would also suggest some techniques I found.
1. How to recover modified records from SQL Server without Backup[^]
2. How to recover SQL Server data from accidental updates without backups[^]

I have tried the first one 1 year before and it worked.

All the best. :)


这篇关于我如何...如何回滚上次更新我执行的SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆