Use transaction logs to recover data loss caused by incorrect Update and Delete operations

Source: Internet
Author: User

Source: http://www.51one.net/

Many of you may have encountered the following problems:
If the update or delete statement does not include the where clause, or the where clause is not accurate enough, the execution may cause serious consequences,
In this case, data recovery can only be performed using the backup of transaction logs. Therefore, if your SQL statement does not have a full database backup
Or the log cannot be backed up (the truncate log on checkpoint option is 1), so data cannot be restored, or
Only the data of the last backup can be restored.

The following describes how to restore data:
1. If a full-Database Backup (or multiple differential or incremental backups exist) exists before the misoperation, the first thing to do is
Perform a log backup (if you set trunc. log on chkpt to 1 to prevent the log file from becoming larger)
Backup log dbName to disk = fileName
2. Recover a full-database backup. Use with norecovery. If there are other differences or incremental backups, recover them one by one.
Replay
Restore database dbName from disk = fileName with norecovery
3. Restore the last log backup, that is, the log backup you just created. Specify the recovery time point to the time before the misoperation.
Restore log dbName from disk = fileName
With stopat = date_time

These operations can be completed in the SQL SERVER Enterprise Manager, which is not difficult...

Of course, if the misoperation involves operations that do not remember logs, such as truncate table and select into, then there is no farli.
Use the above method to restore data...


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.