WHAT IS SCN ?? WHERE IT IS STORED ?? TYPES OF SCN ??
SCN :
Internal timestamp used by the Oracle Database which is necessary to satisfy the ACID properties of a transaction.
The database uses SCNs to query and track changes
Each type of SCN and their location and what they have been called and its purpose
Placestored | Called as | Visible as column | Related View | Purpose |
ControlFile | System SCN | checkpoint _change# | V$database | For recover database using backup control file |
ControlFile | individual datafile SCN | checkpoint _change# | v$datafile | We need this individual SCN for each datafile since there are some datafiles which need recovery due to offline status, this is different from the System SCN above |
ControlFile | Stop SCN | last_change# | v$datafile | For Instance Recovery |
Datafile | Start SCN | checkpoint _change# | v$datafile_header | The start of the SCn when the instance started |
Redofile | HighSCN | Next_change# | V$log_history | The last scn recorded in the redo log files. |
Redofile | LowSCN | FIRST_CHANGE# | V$log | The oldest recorded SCN from where the next redo log file starts. |
Block | BlockSCN | Ex: scn: 0x0000. 00046911 | Dump the blockalter system dump datafile 3 block min 10 block max 12; | Every data block also has block SCN (aka block version). to match up the redo records before applying it |
Redofile | CommitSCN | ITL List header |
v$database
current_scn
dbms_flashback.
get_
system_
change_
number
| Every commit will generate SCN, aka commit SCN, that marks a transaction boundary. |
Redo? PGA? Not sure where it records | SnapshotSCN | When a transaction or query begins, the current SCN is recorded. That SCN serves as the snapshot SCN for the query or transaction | scn: kcmgss in v$sysstat?
Current SCN from v$database?
| When the query starts it has to note down the SCN that current database or block has so that it can report consistent block back |
- Just like a ticker of clock, SCN keep increment at database level via a different background process like AQ, SMON, job queues… etc.
- A checkpoint number is the SCN number at which all the dirty buffers are written to disk. There can be a checkpoint at object/tablespace/datafile/database level.
- Whenever a transaction commits (SCN at redo logs as highest SCN (NEXT_CHANGE#) & lowest SCN (FIRST_CHANGE#) get recorded)
- Whenever a checkpoint occures (SCN get recorded as CHECKPOINT_CHANGE# into database (v$database/system checkpoint) / datafile (v$datafile_header/datafile START SCN) / controlfile (v$datafile/STOP SCN) / Redo entry (v$log/ High SCN & low SCN))
- SCN also recorded for Slot reserved for transaction in undo segment.
- By default a block-level SCN is recorded for each block. (Rows sharing same block can be check using ora_rowscn)
In shutdown normal or shutdown immediate,
When happen checkpoint, will SCN wrote four places to go. Three places in the control file, one in datafile header.
1.System checkpoint SCN ===========> (SYSTEM CHECKPOINT SCN in control file)
2.Datafile checkpoint SCN ===============> (DATAFILE CHECKPOINT SCN in control file)
3.Stop SCN ======================> (STOP SCN in control file)
4.Start SCN ================================> (DATAFILE HEADER)
Why CONTROL FILE stored in two places to be divided (SYSTEM CHECKPOINT SCN, DATAFILE CHECKPOINT SCN?) When you put a tbs set to read-only, SCN will freeze to stop him, this time DATAFILE CHECKPOINT SCN is no longer incremental changes, but the overall SYSTEM CHECKPOINT SCN will continue to increase, but still advancing. So, this is why you need are stored in two places SCN.
Also check out this recovery based articles for more understanding
https://karunadba.blogspot.in/2017/07/difference-between-media-recovery-crash.html
excellent work !!!
ReplyDelete