从 SQL Server 2000 恢复已删除的行
脚本使用以下查询意外地从数据库中删除了几行:
DELETE FROM that_table WHERE id IN (100, 101, 102)
同时添加了更多行。有没有办法让我将三行恢复到同一个表(或者可能是另一个数据库/表)中?我不想恢复数据库,因为这意味着我会丢失该查询后添加/更新的所有数据。手动输入缺失的行是一种选择。
A script accidentally deleted few rows from the database with the following query:
DELETE FROM that_table WHERE id IN (100, 101, 102)
More rows have been added in the mean time. Is there a way for me to recover the three rows into the same table (or perhaps another database/table)? I do not want to restore the database as if this means I lose all data added/updated after that query. Hand entering the missing rows is an option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 ApexSQL Log,这是一种 SQL Server 审核和恢复工具,可以从数据库事务日志中读取信息并为 DML 和 DDL 操作提供撤消 T-SQL 脚本。
免责声明:我在 ApexSQL 担任产品支持工程师
You can use ApexSQL Log, a SQL Server auditing and recovery tool which reads information from database transaction logs and provides undo T-SQL scripts both for DML and DDL operations.
Disclaimer: I work as a Product Support Engineer at ApexSQL
当您使用 SQL Server 2000 时,您可能会幸运地获得免费的 Redgate SQL Log Rescue Tool 适用于此版本。
As you are on SQL Server 2000 you may be in luck as the free Redgate SQL Log Rescue Tool works against this version.
幸运的是,我有一个备份,因此我使用此处描述的过程在同一服务器上但在新数据库下恢复备份:
将完整备份恢复到同一服务器上的新数据库
在新数据库中恢复数据库备份后,我找到了行并将其插入:
以上查询没有立即运行,我必须启用身份插入并暂时禁用一些约束。
Luckily I had a backup so I used the procedure described here to restore the backup on the same server but under a new database:
Restoring a Complete Backup to a New Database on the Same Server
After the database backup was restored in a new database, I located the rows and inserted them:
The above query did not run out of the box, I had to enable identity insert and disable a couple of constraints temporarily.