回滚插入语句

发布于 2024-08-03 04:01:04 字数 75 浏览 3 评论 0原文

我已将大量记录插入到表中。不幸的是,这些记录不应该插入到该表中。逐一删除记录是不可行的。

在这种情况下如何回滚上述记录呢?

I have inserted a significant quantity of records into a table. Unfortunately, these records should not have been inserted in this table. Deletion of the records in a one-by-one fashion is not feasible.

How can one rollback the aforementioned records in this situation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

风启觞 2024-08-10 04:01:04

您可以尝试以下几个其他想法。

在另一个数据库中恢复完整备份,然后使用一些第三方工具比较表,例如 ApexSQL Data DiffdbForgeRed Gate

如果数据库处于完全恢复模式,请尝试读取事务日志。以下是有关此主题的几篇文章:

SQL Server 事务日志资源管理器/分析器

< a href="https://stackoverflow.com/questions/9767054/read-the-log-file-ldf-in-sql-server-2008">读取sql server 2008中的日志文件(*.LDF)

如何在 sql server 2008 中查看事务日志

Here are couple additional ideas you can try.

Restore a full backup in another database and then compare tables using some third party tools such as ApexSQL Data Diff or dbForge or Red Gate

If database was in full recovery mode try reading transaction log. Here are several posts on this topic:

SQL Server Transaction Log Explorer/Analyzer

Read the log file (*.LDF) in sql server 2008

How to view transaction logs in sql server 2008

A君 2024-08-10 04:01:04

假设您执行此操作时并未参与交易,您会发现这个过程很痛苦。不确定您对哪种 DBMS 感兴趣,但这里有一些有关 SQL Server 2005 的信息:

回滚使用事务日志进行事务

本质上,最简单的方法是从插入之前的备份恢复数据库。

Assuming you were not inside a transaction when you did this, you're going to find the process painful. Not sure what flavour of DBMS you're interested in, but here's some info on SQL Server 2005:

Rollback transaction using transaction log

Essentially, the easiest way to do this is to restore your DB from a backup that predates your inserts.

耀眼的星火 2024-08-10 04:01:04

我猜插入语句已提交到数据库,否则您可以简单地执行回滚;

你有审核表吗?如果有一个审计表,您将能够识别在特定日期时间插入的行,然后删除它们......

I am guessing the inserts statements have been committed to the database else you could simply do a ROLLBACK;

Do you have an audit table? If there is an audit table you would be able to identify the rows inserted during a particular datetime and then delete them...

场罚期间 2024-08-10 04:01:04

插入的行是否有任何特征可以使它们与所有其他行区分开来?例如,是否有插入的日期或数字标识列?如果是这样,只需根据该条件进行删除即可。

除此之外,奶油鸡是对的,可能有点痛。但我以前从未使用过这样的事务日志回滚。

Are there any features of the inserted rows that make them distinguishable from all of the others? For example is there an inserted date, or a numeric identity column? If so, just do a delete based on that criteria.

Other than that, butterchicken is right, it's probably a bit painful. But I've never rolled back using a transaction log like that before.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文