如何从表中检索已删除的记录 [英] How to retrieve deleted records from table

查看:65
本文介绍了如何从表中检索已删除的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很遗憾,已从表中删除了记录,因此如何检索表的已删除记录.

unfortunately deleted records from table, so how to retrieve deleted record of table.

推荐答案

如果数据库处于完全恢复模式,则可以还原它时光倒流.否则,您需要还原备份以恢复该数据.

否则你也可以尝试这个

SQL Server为每个删除的记录保留日志.您可以通过"fn_dblog" sql服务器函数查询这些日志.
If your database is in full recovery mode then it is possible to restore it back in time. Otherwise you need to restore a backup to get that data back.

else u can try this also

SQL Server keeps log for each deleted records. you can query these logs via ''fn_dblog'' sql server function.
Select [RowLog Contents 0]
FROM   sys.fn_dblog(NULL, NULL)
WHERE  AllocUnitName = 'dbo.TableName'
       AND Context IN ( 'LCX_MARK_AS_GHOST', 'LCX_HEAP' )
       AND Operation in ( 'LOP_DELETE_ROWS' )


但是此日志为十六进制格式.并且您需要将此十六进制格式转换为您的实际数据.
请参阅以下内容: http://raresql.com/2011/10/22/how-to-recover-deleted-data-from-sql-sever/ [


But this log is in Hex format. and you need to convert this Hex format to your actual data.
refer this: http://raresql.com/2011/10/22/how-to-recover-deleted-data-from-sql-sever/[^]


没有办法.删除数据后,您将无法恢复数据,除非您具有外部恢复选项.

您只能使用
交易 [回滚 [
There is no way to do this. Once you deleted the data, you''ll not be able to recover it, until and unless you have a external recovery option.

You can only prevent the data loss using Transactions[^]. Because a Rollback[^] option is there with it to rollback the data of previous stage.


     --Amit


不要从表中删除记录,只需添加一个新列即可保存是非.当您想要删除它时,只需将该记录的列值更新为false.之后,每当您要撤消已删除的操作时,都会触发另一个更新语句,以将记录的状态更改为true.并且每当您只希望不删除记录时,请在select语句中添加where子句以检查recordStatus以确定它是否被删除,或者使用true或false.
Don''t delete records from your table just add a new column which save true or false. When you want to delete it then just update that record''s column value to false. After that whenever you want to undo the deleted operation fire another update statement to change status of the record to true. And whenever you want only not deleted record add where clause in your select statement to check the recordStatus to determine it is deleted or not using true or false.


这篇关于如何从表中检索已删除的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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