首页 > 数据库 > Oracle > 正文

Oracle10g中的current_scn是如何计算的

2024-08-29 13:51:52
字体:
来源:转载
供稿:网友
问: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.
Connected to:
Oracle Database 10g Enterprise Edition
Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security,
OLAP and Data Mining Scoring Engine options
SQL> @scn
SQL> col current_scn for 99999999999999999
SQL> select current_scn from v$database;
CURRENT_SCN
------------------
8910961765228
SQL> select dbms_flashback.get_system_change_number
current_scn from dual;
CURRENT_SCN
------------------
8910961765228
SQL> select dbms_flashback.get_system_change_number
current_scn from dual;
CURRENT_SCN
------------------
8910961765228
SQL> select current_scn from v$database;
CURRENT_SCN
------------------
8910961765229
SQL> select dbms_flashback.get_system_change_number
current_scn from dual;
CURRENT_SCN
------------------
8910961765229
SQL> select dbms_flashback.get_system_change_number
current_scn from dual;
CURRENT_SCN
------------------
8910961765229
SQL> select current_scn from v$database;
CURRENT_SCN
------------------
8910961765230我们看到current_scn的查询会直接导致SCN的增进,而其他方式并不会。也就是说在这里的current_scn就像是一个Sequence一样,查询会导致增进。这也很好理解,v$database只能通过增进当前的SCN才能保证获得的SCN是Current的。可是假如不查询呢?这个值肯定是不会增长的。也就是说你不查询就不知道current_scn的值,只要查询它就会出现变化。


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表