Comparing Undo Data and Redo Data in Oracle

Comparing Undo Data and Redo Data in Oracle

In this article, we will compare Undo and Redo data and the differences between them in Oracle. Please read our previous article discussing Transactions and Undo Data in Oracle.

Comparing Undo Data and Redo Data in Oracle

UNDO and Redo operations are two different things. We have learned about the redo operation for a long time. In the beginning, we discussed the database files. Redo log files are one of the database files. There is a big difference between UNDO data and redo data. Redo log files store changes to the database as they occur and are used for data recovery. For example, if a user opens a session and makes an update statement for the table emp, changing the sal value to 500 where id =10.

Statement: update emp set sal=500 where id = 10; commit;

Comparing Undo Data and Redo Data in Oracle

When we perform this operation, this change will not reflect directly on the database files. It will first be stored in the redo log files. So, the redo log files contain changes to the database.

The changes aren’t stored directly in the database file because this will cause bad performance. Every user who makes changes to the database may have fewer chances to issue a commit. The data will first be written to the redo log files and then, under certain conditions, moved to the data files. So, the redo log files contain all the changes you make to the database for the database recovery.

Undo and Redo data and the differences between them in Oracle

Redo Log Files in Oracle

Redo Log Files in Oracle

Let us take an Oracle database named dotnet_db1. The backup of this database is initiated at 2 PM, and the backup file is stored in another location. At 4 PM, the database crashed, and all the data was lost. It is more important to restore the data back to dotnet_db1. We need to look into the files and determine how to restore the entire database to normal.

Now we have the backup file, which was taken back up at 2 PM. So, the data will be available till 2 PM. What about the remaining transactions between 2 PM and 4 PM? Now, the archive redo log files have come into place. It stores all the changes that happen to the database. So, we can use the archived redo log files to recover the data from 2 PM to 4 PM, and using these backup files and archived redo log files, we can restore the database and put it in the normal situation.

This is the basic information that is needed for the undo and redo operations that are happening in the database. In the next article, I will discuss Creating a new Pluggable Database in Oracle. In this article, I explain how to Compare Undo Data and Redo Data in Oracle with examples. I hope you enjoy this Comparing Undo Data and Redo Data in Oracle article.

Leave a Reply

Your email address will not be published. Required fields are marked *