以下的文章主要向你解答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的。可是如果不查詢呢?這個值肯定是不會增長的。以上的相關內容就是對Oracle10g的current_scn計算的介紹,望你能有所收獲。