Oracle数据库中的4种SCN号
来源:互联网 发布:一致性哈希算法的用途 编辑:程序博客网 时间:2024/05/19 17:49
一个SCN号就是一个oracle数据库中使用的逻辑的、内部的时间戳。这个SCN号可以表明一个事件在oracle数据库中发生的精确时间。
Oracle数据库中的SCN号分为四种,分别为:系统检查点SCN、数据文件scn、结束scn:、数据文件头scn。
系统检查点SCN:
系统检查点SCN位于控制文件中,当检查点进程启动时(ckpt),Oracle就把系统检查点的SCN存储到控制文件中。
查询系统检查点SCN的命令如下SQL> select CHECKPOINT_CHANGE# from v$database;CHECKPOINT_CHANGE#------------------ 2017133
数据文件SCN:
当ckpt进程启动时,包括全局范围的(比如日志切换)以及文件级别的检查点(将表空间置为只读、begin backup或将某个数据文件设置为offline等),这时会在控制文件中记录的scn。
查询数据文件SCN的命令如下
SQL> select a.TS#,a.name,b.name,b.checkpoint_change# from v$tablespace a, v$datafile b where a.ts#=b.ts#(+) order by ts#; TS# NAME NAME CHECKPOINT_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ 0 SYSTEM /u01/app/oracle/oradata/PROD1/system01.dbf 2028292 1 SYSAUX /u01/app/oracle/oradata/PROD1/sysaux01.dbf 2028292 2 UNDOTBS1 /u01/app/oracle/oradata/PROD1/undotbs01.dbf 2028292 3 TEMP 4 USERS /u01/app/oracle/oradata/PROD1/users01.dbf 2028292 6 EXAMPLE /u01/app/oracle/oradata/PROD1/example01.dbf 2028292 7 TEST /u01/app/oracle/oradata/PROD1/test.tbs 2028292 8 DEV_MDS /u01/app/oracle/oradata/PROD1/DEV_mds.dbf 2028292 9 DEV_IAS_TEMP10 DEV_BIPLATFORM /u01/app/oracle/oradata/PROD1/DEV_biplatform.dbf 202829211 DEV1_ODI_TEMP13 DEV2_ODI_TEMP14 DEV2_ODI_USER /u01/app/oracle/oradata/PROD1/DEV2_odi_user.dbf 202829213 rows selected.SQL> alter tablespace test read only;Tablespace altered.SQL> select a.TS#,a.name,b.name,b.checkpoint_change# from v$tablespace a, v$datafile b where a.ts#=b.ts#(+) order by ts#; TS# NAME NAME CHECKPOINT_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ 0 SYSTEM /u01/app/oracle/oradata/PROD1/system01.dbf 2028292 1 SYSAUX /u01/app/oracle/oradata/PROD1/sysaux01.dbf 2028292 2 UNDOTBS1 /u01/app/oracle/oradata/PROD1/undotbs01.dbf 2028292 3 TEMP 4 USERS /u01/app/oracle/oradata/PROD1/users01.dbf 2028292 6 EXAMPLE /u01/app/oracle/oradata/PROD1/example01.dbf 2028292 7 TEST /u01/app/oracle/oradata/PROD1/test.tbs 2028314 8 DEV_MDS /u01/app/oracle/oradata/PROD1/DEV_mds.dbf 2028292 9 DEV_IAS_TEMP10 DEV_BIPLATFORM /u01/app/oracle/oradata/PROD1/DEV_biplatform.dbf 202829211 DEV1_ODI_TEMP13 DEV2_ODI_TEMP14 DEV2_ODI_USER /u01/app/oracle/oradata/PROD1/DEV2_odi_user.dbf 202829213 rows selected.SQL> alter tablespace test read write;Tablespace altered.SQL> select a.TS#,a.name,b.name,b.checkpoint_change# from v$tablespace a, v$datafile b where a.ts#=b.ts#(+) order by ts#; TS# NAME NAME CHECKPOINT_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ 0 SYSTEM /u01/app/oracle/oradata/PROD1/system01.dbf 2028292 1 SYSAUX /u01/app/oracle/oradata/PROD1/sysaux01.dbf 2028292 2 UNDOTBS1 /u01/app/oracle/oradata/PROD1/undotbs01.dbf 2028292 3 TEMP 4 USERS /u01/app/oracle/oradata/PROD1/users01.dbf 2028292 6 EXAMPLE /u01/app/oracle/oradata/PROD1/example01.dbf 2028292 7 TEST /u01/app/oracle/oradata/PROD1/test.tbs 2028338 8 DEV_MDS /u01/app/oracle/oradata/PROD1/DEV_mds.dbf 2028292 9 DEV_IAS_TEMP10 DEV_BIPLATFORM /u01/app/oracle/oradata/PROD1/DEV_biplatform.dbf 202829211 DEV1_ODI_TEMP13 DEV2_ODI_TEMP14 DEV2_ODI_USER /u01/app/oracle/oradata/PROD1/DEV2_odi_user.dbf 202829213 rows selected.SQL> alter system checkpoint;System altered.SQL> select a.TS#,a.name,b.name,b.checkpoint_change# from v$tablespace a, v$datafile b where a.ts#=b.ts#(+) order by ts#; TS# NAME NAME CHECKPOINT_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ 0 SYSTEM /u01/app/oracle/oradata/PROD1/system01.dbf 2028370 1 SYSAUX /u01/app/oracle/oradata/PROD1/sysaux01.dbf 2028370 2 UNDOTBS1 /u01/app/oracle/oradata/PROD1/undotbs01.dbf 2028370 3 TEMP 4 USERS /u01/app/oracle/oradata/PROD1/users01.dbf 2028370 6 EXAMPLE /u01/app/oracle/oradata/PROD1/example01.dbf 2028370 7 TEST /u01/app/oracle/oradata/PROD1/test.tbs 2028370 8 DEV_MDS /u01/app/oracle/oradata/PROD1/DEV_mds.dbf 2028370 9 DEV_IAS_TEMP10 DEV_BIPLATFORM /u01/app/oracle/oradata/PROD1/DEV_biplatform.dbf 202837011 DEV1_ODI_TEMP13 DEV2_ODI_TEMP14 DEV2_ODI_USER /u01/app/oracle/oradata/PROD1/DEV2_odi_user.dbf 202837013 rows selected.从上述结果中可以看到当我们将test表空间转换为read only状态后,他的scn号比其他数据未见SCN号要大。
结束SCN:
每个数据文件都有一个结束scn,在数据库的正常运行中,只要数据文件在线且是可读写的,结束scn为null。否则则存在具体的scn值。结束scn也记录在控制文件中。
SQL> select a.TS#,a.name,b.name,b.checkpoint_change#,b.LAST_CHANGE# from v$tablespace a, v$datafile b where a.ts#=b.ts#(+) order by ts#; TS# NAME NAME CHECKPOINT_CHANGE# LAST_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ ------------ 0 SYSTEM /u01/app/oracle/oradata/PROD1/system01.dbf 2028370 1 SYSAUX /u01/app/oracle/oradata/PROD1/sysaux01.dbf 2028370 2 UNDOTBS1 /u01/app/oracle/oradata/PROD1/undotbs01.dbf 2028370 3 TEMP 4 USERS /u01/app/oracle/oradata/PROD1/users01.dbf 2028370 6 EXAMPLE /u01/app/oracle/oradata/PROD1/example01.dbf 2028370 7 TEST /u01/app/oracle/oradata/PROD1/test.tbs 2028370 8 DEV_MDS /u01/app/oracle/oradata/PROD1/DEV_mds.dbf 2028370 9 DEV_IAS_TEMP10 DEV_BIPLATFORM /u01/app/oracle/oradata/PROD1/DEV_biplatform.dbf 202837011 DEV1_ODI_TEMP TS# NAME NAME CHECKPOINT_CHANGE# LAST_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ ------------13 DEV2_ODI_TEMP14 DEV2_ODI_USER /u01/app/oracle/oradata/PROD1/DEV2_odi_user.dbf 202837013 rows selected.SQL> alter tablespace test read only;Tablespace altered.SQL> select a.TS#,a.name,b.name,b.checkpoint_change#,b.LAST_CHANGE# from v$tablespace a, v$datafile b where a.ts#=b.ts#(+) order by ts#; TS# NAME NAME CHECKPOINT_CHANGE# LAST_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ ------------ 0 SYSTEM /u01/app/oracle/oradata/PROD1/system01.dbf 2028370 1 SYSAUX /u01/app/oracle/oradata/PROD1/sysaux01.dbf 2028370 2 UNDOTBS1 /u01/app/oracle/oradata/PROD1/undotbs01.dbf 2028370 3 TEMP 4 USERS /u01/app/oracle/oradata/PROD1/users01.dbf 2028370 6 EXAMPLE /u01/app/oracle/oradata/PROD1/example01.dbf 2028370 7 TEST /u01/app/oracle/oradata/PROD1/test.tbs 2029996 2029996 8 DEV_MDS /u01/app/oracle/oradata/PROD1/DEV_mds.dbf 2028370 9 DEV_IAS_TEMP10 DEV_BIPLATFORM /u01/app/oracle/oradata/PROD1/DEV_biplatform.dbf 202837011 DEV1_ODI_TEMP TS# NAME NAME CHECKPOINT_CHANGE# LAST_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ ------------13 DEV2_ODI_TEMP14 DEV2_ODI_USER /u01/app/oracle/oradata/PROD1/DEV2_odi_user.dbf 202837013 rows selected.
可见test表空间的数据文件结束SCN不为空,而其他数据文件结束SCN均为空。
如果将数据库处于mount状态下,所有数据文件均不可写,所以都具有结束SCN。
SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 722366464 bytesFixed Size 2216864 bytesVariable Size 251661408 bytesDatabase Buffers 461373440 bytesRedo Buffers 7114752 bytesDatabase mounted.SQL> select a.TS#,a.name,b.name,b.checkpoint_change#,b.LAST_CHANGE# from v$tablespace a, v$datafile b where a.ts#=b.ts#(+) order by ts#; TS# NAME NAME CHECKPOINT_CHANGE# LAST_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ ------------ 0 SYSTEM /u01/app/oracle/oradata/PROD1/system01.dbf 2030818 2030818 1 SYSAUX /u01/app/oracle/oradata/PROD1/sysaux01.dbf 2030818 2030818 2 UNDOTBS1 /u01/app/oracle/oradata/PROD1/undotbs01.dbf 2030818 2030818 3 TEMP 4 USERS /u01/app/oracle/oradata/PROD1/users01.dbf 2030818 2030818 6 EXAMPLE /u01/app/oracle/oradata/PROD1/example01.dbf 2030818 2030818 7 TEST /u01/app/oracle/oradata/PROD1/test.tbs 2029996 2029996 8 DEV_MDS /u01/app/oracle/oradata/PROD1/DEV_mds.dbf 2030818 2030818 9 DEV_IAS_TEMP10 DEV_BIPLATFORM /u01/app/oracle/oradata/PROD1/DEV_biplatform.dbf 2030818 203081811 DEV1_ODI_TEMP TS# NAME NAME CHECKPOINT_CHANGE# LAST_CHANGE#---------- -------------------------------------------------- -------------------------------------------------- ------------------ ------------13 DEV2_ODI_TEMP14 DEV2_ODI_USER /u01/app/oracle/oradata/PROD1/DEV2_odi_user.dbf 2030818 203081813 rows selected.
数据文件头SCN:
不同于上述的SCN数据文件开始scn记录在每个数据文件中。当发生系统及文件级别的检查点后,不仅将这时的SCN号记录在控制文件中,同样也记录在数据文件中。
查询数据文件头SCN的命令如下SQL> select tablespace_name,file#,CHECKPOINT_CHANGE# from v$datafile_header;TABLESPACE_NAME FILE# CHECKPOINT_CHANGE#------------------------------ ---------- ------------------SYSTEM1 2030818SYSAUX2 2030818UNDOTBS13 2030818USERS4 2030818EXAMPLE 5 2030818TEST6 2029996DEV_MDS 7 2030818DEV_BIPLATFORM8 2030818DEV2_ODI_USER9 20308189 rows selected.
0 0
- Oracle数据库中的4种SCN号
- 浅谈Oracle数据库SCN号
- 浅谈Oracle数据库SCN号
- oracle数据库scn号查询
- oracle 数据库,无效的SCN号错误
- oracle数据库SCN概念
- oracle中的检查点ckpt和scn号
- oracle中的检查点Ckpt和SCN号
- oracle中的检查点Ckpt和SCN号
- Oracle 中的 SCN
- 浅析oracle中的SCN
- 了解oracle中的SCN
- 数据库一致性研究【Oracle SCN】
- oracle中的 resetlogs+scn恢复
- oracle中的 resetlogs+scn恢复
- ORACLE中的各种SCN查询
- ORACLE中的各种SCN查询
- SCN号与oracle数据库恢复的关系
- qt编译oracle oci数据库驱动(一)
- android开发之动态给HorizontalScrollView添加被包含控件
- Android系统回顾(四):Android应用程序的生命周期
- Linux常用命令收集
- 面试经常问到的集合类
- Oracle数据库中的4种SCN号
- STL库全排列算法next_permutation
- 管理服务
- LeetCode Combination Sum II
- 圆形imageview(RoundedImageView)
- Iterator与ListIterator有什么区别?
- 程序人生
- 在Linux上安装Memcached服务和php扩展
- Android开发兼容不同的屏幕大小