The SCN is something like the internal clocks of oracle.
Before the start, every transaction will get a current SCN from the database. For this, the kcmgss routine is used.kcmgss - kernel cache get snapshot scn
After every commit or rollback, the SCN is changed. For this, the kcgas routine is used.
kcmgas - kernel cache get and advance scn
The other routines that can e called are:
kcmgss - get snapshot SCN
kcmgas - get and advance the SCN
kcmgrs - get recent SCN
kcmgcs - get current scn
After the commit, the redo log buffer is flushed to disk and the SCN of that transaction is writen in the redo log file.
To get the current SCN you can use:
select current_scn from v$database; <-- This select will increment the value of the SNC. This can be seen in the v$mystat view. The count of the kcgmss and kcgas wil be incremented.
select dbms_flashback.get_system_change_number from dual; <- this select will not increment the SCN.
The SCN consits of base_scn and wrap_scn. Whenever the base SCN reaches it limits, the wrap scn will be inecremented and the base scn will start from the 0 again.
Tthe maximal value of the SCN should be somewhere at 281 trilion.
When the checkpoint is issued, the checkpoint SCN is writen in the controlfile and in the header of the datafiles.
So when the instance is started, the SCN from controlfiles and datafiles is compared and if it differs, the recovery is needed. Oracle then takes the SCN from datafiles and reads and applies the whole redo log. After this, all uncommited transactions are rolled back.
When we change the row in the DB we have to:
-- Read the block to the memory
-- Modify the data
-- The modification will generate the redo (to redo the change)
-- It will also generate the undo (to undo that change)
-- and it will also generate the redo (to redo the change on the undo block)
After every commit or rollback, the SCN is changed. For this, the kcgas routine is used.
kcmgas - kernel cache get and advance scn
The other routines that can e called are:
kcmgss - get snapshot SCN
kcmgas - get and advance the SCN
kcmgrs - get recent SCN
kcmgcs - get current scn
After the commit, the redo log buffer is flushed to disk and the SCN of that transaction is writen in the redo log file.
To get the current SCN you can use:
select current_scn from v$database; <-- This select will increment the value of the SNC. This can be seen in the v$mystat view. The count of the kcgmss and kcgas wil be incremented.
select dbms_flashback.get_system_change_number from dual; <- this select will not increment the SCN.
The SCN consits of base_scn and wrap_scn. Whenever the base SCN reaches it limits, the wrap scn will be inecremented and the base scn will start from the 0 again.
Tthe maximal value of the SCN should be somewhere at 281 trilion.
When the checkpoint is issued, the checkpoint SCN is writen in the controlfile and in the header of the datafiles.
So when the instance is started, the SCN from controlfiles and datafiles is compared and if it differs, the recovery is needed. Oracle then takes the SCN from datafiles and reads and applies the whole redo log. After this, all uncommited transactions are rolled back.
When we change the row in the DB we have to:
-- Read the block to the memory
-- Modify the data
-- The modification will generate the redo (to redo the change)
-- It will also generate the undo (to undo that change)
-- and it will also generate the redo (to redo the change on the undo block)