Database recovery is the process of restoring a database to a correct state after failures to prevent data loss, which can occur due to crashes, media failures, or human errors. It utilizes transaction logs for rollback and roll forward methods, with checkpoints speeding up recovery by saving completed transactions. SQL commands for backing up, restoring, and rolling forward transactions are provided as practical examples.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
11 views14 pages
Database Recovery Presentation Final
Database recovery is the process of restoring a database to a correct state after failures to prevent data loss, which can occur due to crashes, media failures, or human errors. It utilizes transaction logs for rollback and roll forward methods, with checkpoints speeding up recovery by saving completed transactions. SQL commands for backing up, restoring, and rolling forward transactions are provided as practical examples.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14
Database Recovery Points
Simple Explanation with Examples
What is Database Recovery? • Restoring a database to a correct state after a failure to prevent data loss. Why is Database Recovery Needed? • - System Crashes (Power Outage) • - Media Failures (Hard Disk Crash) • - Human Errors (Accidental Deletion) Example: Lost Document • Imagine writing an important document and your computer crashes before saving. • Database recovery is like recovering your last saved version. How Database Recovery Works? • - Uses a Transaction Log to track changes • - Rollback: Undo incomplete transactions • - Roll Forward: Reapply completed transactions Two Recovery Methods • 1. Manual Reprocessing (Slow, Error-prone) • 2. Automated Recovery (Uses Logs, Faster) What is a Checkpoint? • A checkpoint saves all completed transactions to disk. • Recovery starts from the last checkpoint instead of starting from scratch. Key Takeaways • ✔ Database recovery prevents data loss • ✔ Rollback & Roll Forward fix transactions • ✔ Checkpoints speed up recovery SQL Code: Backup Database • BACKUP DATABASE MyDatabase • TO DISK = 'C:\Backup.bak' • WITH FORMAT; SQL Code: Restore Database • RESTORE DATABASE MyDatabase • FROM DISK = 'C:\Backup.bak' • WITH NORECOVERY; SQL Code: Roll Forward • RESTORE LOG MyDatabase • FROM DISK = 'C:\Backup.trn' • WITH RECOVERY; SQL Code: Backup Database • -- This command creates a full backup of the database • BACKUP DATABASE MyDatabase • TO DISK = 'C:\Backup.bak' • WITH FORMAT;
• 🔹 Example: Imagine saving your work before
making changes. If something goes wrong, you can restore it back! SQL Code: Restore Database (Rollback) • -- This restores the database but keeps it in a 'restoring' state • RESTORE DATABASE MyDatabase • FROM DISK = 'C:\Backup.bak' • WITH NORECOVERY;
• 🔹 Example: Think of pausing a movie before
watching the end. You can still add more transactions before finishing the restore. SQL Code: Roll Forward (Redo Transactions) • -- This applies all committed transactions and makes the database usable • RESTORE LOG MyDatabase • FROM DISK = 'C:\Backup.trn' • WITH RECOVERY;
• 🔹 Example: Imagine rewriting lost pages of a
book using notes you saved. This command brings back the missing transactions.