一 SCN概念
System Change Number. A database ordering primitive. The value of an SCN is the logical point in time at which changes are made to a database.
The system change number (SCN) is Oracle's clock - every time we commit, the clock increments. The SCN just marks a consistent point in time in the database.
A checkpoint is the act of writing dirty (modified blocks from the buffer cache to disk.
The database ALWAYS has transactions going on, ALWAYS. SMON and many other background processes are always doing work, the database (unless it is opened read only) is always doing transactions.
SCN号与oracle数据库恢复过程有着密切的关系,只有很好地理解了这层关系,才能深刻地理解恢复的原理,从而才能很好地解决这方面的问题。
SCN与CKPT进程在checkpoint发生时,将当时的SCN号写入数据文件头和控制文件,同时通知DBWR进程将数据块写到数据文件。
CKPT进程也会在控制文件中记录RBA(redo block address),以标志Recovery需要从日志中哪个地方开始。与checkpoint相关的SCN号有四个,其中三个存在控制文件中,一个存放在数据文件头中,下面将分别介绍。
二 SCN分类
1 系统检查点scn(System Checkpoint SCN)
当一个检查点动作完成后,Oracle就把系统检查点的SCN存储到控制文件中。
SQL:SELECT checkpoint_change#,scn_to_timestamp(checkpoint_change#)+0,current_scn,scn_to_timestamp(current_scn)+0 FROM v$database;