如何撤消sql查询 [英] how to do undo a sql query

查看:96
本文介绍了如何撤消sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,请看下面的queris并给我一个解决方案。





update emp_table set salary = 500000(在这里我没有给出条件,显然所有记录都会更新)



在这里我想要撤消任何如此因为这个表中有超过一万条记录和对于不同的员工现在有不同的工资,我现在意外地解雇了上面的查询,它让我陷入了一个非常大的喧嚣。请尽快给我一些技巧。



非常感谢提前

Hi every one,please see following queris and give me a solution.


"update emp_table set salary=500000"(Here i failed to give condition ,obviously all record will be updated)

Here i want to do undo any how becouse in this table there is more than Ten thousand records and for different employee there is different salary now accidently i fired the above query ,it puts me in a very big trubble.Please geive me some tricks as soon as possible .

Thanks a lot in advance

推荐答案

如果您已经执行了没有事务的语句,那么它将被提交到数据库。在这种情况下,您可以将数据库恢复到以前的状态。



但是,如果这样做,您可能会丢失备份后进行的修改。因此,一种可能性是将备份还原到一个全新的SQL Server数据库(甚至是实例),然后使用该数据库从表中获取所有原始值并将它们放在实际表中。
If you have already executed the statement without transaction, it's committed to the database. In that case, you can restore the database to a previous situation.

However, if you do that, you may loose modifications that are made after the backup. So One possibility is that you restore the backup to a whole new SQL server database (or even instance) and then using that database fetch all the original values from the table and put them in place in your actual table.


您可以使用以下事项:

You can use transactions for this :
begin tran
update emp_table set salary=500000

select * from emp_table

-- rollback tran
-- commit tran



您可以使用上面的测试进行测试,如果一切正常,请使用 commit tran else rollback tran


如果您备份了以前的数据r estore it。

您只能回滚没有交易而不查询的交易。
If you have back up of previous data restore it.
You can roll back only transactions not query without transaction.


这篇关于如何撤消sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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