Welcome 微信登录

首页 / 数据库 / MySQL / Oracle10g中的current_scn是怎样计算的

问: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的值,只要查询它就会出现变化。ubuntu下更改mysql默认编码(字符集)设置Ubuntu下的MySQL相关资讯      oracle10g 
  • 在Oracle Linux 5.11上构建基于LVM  (02月14日)
  • Oracle10g DG 的搭建  (10/26/2013 07:27:57)
  • Oracle10g scott解锁  (07/28/2012 06:12:32)
  • Oracle10g 64位 在Windows 2008   (12/19/2015 13:24:57)
  • Oracle Enterprise Linux 5.6安装  (08/30/2012 08:46:56)
  • RHEL5.5_x86_64 上安装Oracle10g   (05/07/2010 10:05:47)
本文评论 查看全部评论 (0)
表情: 姓名: 字数