分类: Oracle
2008-04-03 21:36:24
前几天有一个朋友问我一个问题:
Oracle10g的current_scn是如何计算的?
我们知道Oracle10g在v$database视图中引入了current_scn,这个SCN来自底层表,代表当前的SCN,在Oracle9i中我们可以通过dbms_flashback.get_system_change_number来获得系统的SCN。
但是注意current_scn还是有所不同的,我们看一下一个查询:
[oracle@danaly ~]$ sqlplus '/ as sysdba'
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 21 10:15:08 2007 Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> @scn CURRENT_SCN SQL> select dbms_flashback.get_system_change_number current_scn from dual; CURRENT_SCN SQL> select dbms_flashback.get_system_change_number current_scn from dual; CURRENT_SCN SQL> select current_scn from v$database; CURRENT_SCN SQL> select dbms_flashback.get_system_change_number current_scn from dual; CURRENT_SCN SQL> select dbms_flashback.get_system_change_number current_scn from dual; CURRENT_SCN SQL> select current_scn from v$database; CURRENT_SCN |
也就是说你不查询就不知道current_scn的值,你查询它就变化,是不是有点向薛定谔的猫的那种感觉?
-The End-