redo -> undo -> datafile
insert a record, the table will put the information with the undo redo, in the commit or before, redo information will be put in the hard disk. Failure, redo will return to those who have commit the data.
Each operation are first recorded in the redo log, when there is an instance failure (like power), resulting in failure to update the data to the data file, restart the database to be redo, re-update the data to the data file.
Recorded before the change of a copy, but when your system rollback to the back cover copy to the original data
redo-> record of all operations for the recovery (redo records all the database transaction used for recovery)
undo-> record all of the former impression, used to roll back (undo is used to store uncommited data infor used for rollback)
redo-> transaction has been submitted, the instance data file recovery going to be written
undo-> did not submit the transaction.
redo reason: each commit, data will be immediately written to online redo changes, but not necessarily at the same time writes the data to modify the data file. Because the data has been submitted, but only in the online log file, so you need to restore data from the online log file to find out, re-application, so as to change the data in the data file has also changed over!
undo the reason is: oracle normal operation, in order to improve efficiency, add user does not commit, but the free memory is limited, by the DBWR process to write dirty blocks to the data file in order to free precious memory for other processes use. This reason is the need to UNDO. Because it has not issued a commit statement, but the oracle of dbwr process has not submitted the data to write data files go.
undo is also a datafile, probably dirty buffer is not written back to disk to go inside.
Only the first redo apply successful, to ensure undo datafile things that are right there before you can rollback.
The purpose is to do redo the system back to a system crash before (before shutdown) state, then the undo is to ensure system consistency.
Not to redo, the system will not know the state before, undo impossible.
So instance crash recovery time is always the first rollforward, and then rollback
Rollback segment data is based on "fallback entry" stored.
Item = back block information (change occurred in the affairs of the number of blocks) + before submitting the transaction data stored in the block
In each rollback segment in oracle for its maintenance are a "transaction table"
Recorded in the transaction table, rollback segment and the rollback entries for all matters related to the number (SCN & Services back items)
Redo log by a group of "change vector" component.
Change the variables recorded for each transaction in a database block changes.
When a user submits a commit statement, LGWR process will immediately submit a written record to the redo log file, and then began to write and redo information related to the transaction.
After the success of a transaction is committed, Oracle will be prepared for things to change a system generated code (SCN). Transactions recorded in the SCN will also submit its records, and redo records.
commit overhead there are two factors:
A. obviously will increase the round-trip communication with the database. If each record submitted, and from the traffic generated would be much larger.
B. Each submission must wait for redo is written to disk. This will lead to "wait." In this case, waiting for a "log file sync" (log file sysnc)
Commit the transaction (COMMIT) to complete the work:
# Back in the SGA buffer zone to generate the transaction rollback entries. Back entry in the preservation of the firm to modify the original version of the data.
# In the SGA redo log buffer zone to generate the transaction redo records. Redo records in the records of the transaction conducted on the data block changes, and also recorded on the rollback segment data block of the modifications. Redo records in the cache may be written before the transaction commits the hard disk.
# Slow in the SGA area abundance recorded in the database transaction carried out the database changes. These changes may also be submitted in the transaction to write to the hard drive before.
Commit the transaction (COMMIT) completed at work:
# Specified in the transaction rollback segment in the internal affairs of the table records the transaction has been committed, and generates a unique SCN recorded in the internal affairs of the table, used to uniquely identify the transaction.
# LGWR process of backward areas will be SGA redo log buffer is written in the redo records online redo log files. Redo log writing will also write to the transaction SCN.
# Oracle server process with the release of all records office lock and table lock.
# Oracle notifies the user to complete the transaction commits.
# Oracle marks the transaction as completed.
During the oracle, LGWR is not cached all the work you do; In fact, with the conduct of your work, LGWR amount of style in the background had to refresh the contents of the output redo log buffer to an online redo log files in COMMIT This is done to avoid a long wait to flush the output once all the redo. Until commit implementation, LGWR until all remaining redo log entries to write cache to disk, and records of the SCN to the online redo log files. This part is the real COMMIT, then transaction entries will be removed from the V $ TRANSACTION, indicating that we have submitted.
rollback transaction rollback the work done:
· Oracle by using the rollback segment back in the entry to remove all the SQL statements in the transaction to the database changes.
· Oracle server process the release of Office to use Oracle informed of all matters back lock successful.
· Oracle has completed the transaction is marked as
insert into a (id) values (1); (redo)
This record is the need to roll back.
Rollback statement is delete from a where id = 1; (undo)
Just want to see. If you do not do insert into a (id) values (1); (redo)
Then delete from a where id = 1; (undo) this sentence does not make sense.
Now have a look right recovery:
The first insert into a (id) values (1); (redo)
Then delete from a where id = 1; (undo)
System returned to its original state, without this record.