About the SCN understanding

Source: Internet
Author: User
Tags contains header log terminates

About the SCN understanding
System Checkpoint SCN (V$database (checkpoint_change#))
Data file Checkpoint (V$datafile (checkpoint_change#))
Data file termination SCN (V$datafile (last_change#))

Checkpoints stored in data files
Start SCN (V$datafile_header (checkpoint_change#)

1. System Checkpoint SCN
When a checkpoint action is complete, Oracle stores the SCN of the system checkpoint in the control file.
Select checkpoint_change# from V$database
2. data file checkpoint SCN
When a checkpoint action is complete, Oracle stores the SCN of each data file separately in the control file.
Select name,checkpoint_change# from V$datafile
3. Start SCN
Oracle stores the SCN of this checkpoint in the file header of each data file, which is called the start SCN,
Because it is used to check that database recovery is required when the database instance is started.
Select name,checkpoint_change# from V$datafile_header
4, terminate the SCN
The termination SCN for each data file is stored in the control file.
Select name,last_change# from V$datafile
During normal database operations, all data files that are in the online read-write mode are terminated by a null SCN.
5. SCN value during database operation
After the database is opened and running, the system checkpoint in the control file, the data files in the control file checkpoint SCN
And the start SCN in each data file header is the same. The termination SCN for each data file in the control file is null.

During a secure shutdown of the database, the system performs a checkpoint action, at which point the termination of all data files SCN
will be set to the value of the start SCN in the header of the data file. When the database is restarted,
Oracle compares the boot SCN in the file header with the database file checkpoint SCN.
If these two values match each other, Oracle will then compare the start SCN and control files in the header of the data file
Terminates the SCN for data files in. If these two values are also consistent, it means that all the data blocks have been submitted, all
Changes to the database are not lost during the shutdown of the database, so the process of starting the database this time
No recovery operation is required, and the database can be opened at this time. When all the databases are open,
The value of the data file that is stored in the control file terminates the SCN and is again changed to NULL.
This means that the data file is open and functioning properly.
------------------------------------------
Clarify several concepts
1 The current SCN does not change when any database operation occurs, and the SCN changes when the transaction commits or rolls back.
2 There are SCN in the control file, data file header, data block, log file header, log file change vector, but the function is different. The data file header contains the checkpoint SCN of the data file, The SCN that represents the most recent checkpoint operation for the data file. The log file header contains the low Scn,next SCN, which indicates that the log file contains a redo record from the low SCN to the next SCN. The control file contains the checkpoint of each data file Scn,stop SCN, per log file of the low Scn,next SCN. The checkpoint SCN in the control file is the same as the checkpoint SCN in the header of the data file, unless the data file is manually replaced. Low scn,next in the control file The SCN is the same as the low SCN and next SCN in the same log file when the database is running correctly, the stop SCN for the corresponding data file in the control file is the maximum. In the case of a normal shutdown of the database, A checkpoint is performed before closing when Oracle writes all the contents of the data buffer back to disk, then updates the stop SCN for the corresponding data file in the control file to equal the checkpoint SCN

However, in the case of abnormal, because the last checkpoint was not carried out or the middle was aborted, so in the control file, the existence of a part of the data file stop SCN for the maximum, after the database restart, check the control file corresponding to each data file of the stop SCN, if the stop The SCN does not equal the checkpoint SCN for each data file in the control file, and the log file is used to redo all database operations from the beginning of the checkpoint SCN to the stop SCN. When locating which redo log file is used, The low scn,next SCN in the header of the log file is used, which means the low SCN of the redo log to be used, and the next SCN must contain the change vector required to redo the data file.

After determining which data file has to be redo, Oracle compares the SCN in the change vector and the SCN in the data file block, and if the SCN of the change vector is less than the SCN of the data block, the change vector is skipped, otherwise redo
There is also a SCN in the data block, but it is used to produce a consistent read snapshot



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.