發(fā)布于:2021-02-20 00:00:50
0
289
0
Oracle GoldenGate 18c現(xiàn)在支持Oracle數(shù)據(jù)庫12c中引入的一些新功能,即支持身份列和數(shù)據(jù)庫內(nèi)行存檔中的。
Identity columns允許我們指定一個列應(yīng)該從系統(tǒng)創(chuàng)建的序列中自動填充,該序列類似于MySQL中的AUTO_INCREMENT列或sqlserver中的Identity列。 Oracle 12c信息生命周期管理(ILM)功能稱為數(shù)據(jù)庫歸檔,它使數(shù)據(jù)庫能夠區(qū)分活動數(shù)據(jù)和“較舊”的非活動數(shù)據(jù),同時將所有數(shù)據(jù)存儲在同一數(shù)據(jù)庫中。 當我們?yōu)橐粋€表啟用行存檔時,一個名為ORA_ARCHIVE_STATE column的隱藏列被添加到該表中,該列被自動賦值為0以表示當前數(shù)據(jù),我們可以決定表中哪些數(shù)據(jù)被視為行存檔的候選數(shù)據(jù),并將其賦值為1 一旦區(qū)分了較舊和較新的數(shù)據(jù),我們就可以存檔和壓縮較舊的數(shù)據(jù)以減小數(shù)據(jù)庫的大小,或者將較舊的數(shù)據(jù)移動到較便宜的存儲層以降低存儲數(shù)據(jù)的成本。 請注意,Oracle GoldenGate支持這些功能需要Oracle Database 18c及以上版本。它還需要使用集成提取和集成復制或集成并行復制 身份列 請注意,表POSITION_ID中的IDENTITY COLUMN會自動填充。 SQL> insert into hr.job_positions 驗證摘錄是否捕獲了更改 GGSCI (rac01.localdomain) 3> stats ext1 latest 驗證是否已對目標表執(zhí)行了復制 SQL> select * from hr.job_positions; 在數(shù)據(jù)庫內(nèi)行存檔中 啟用的行存檔系統(tǒng).MYOBJECTS桌子。此表基于數(shù)據(jù)字典對象ALL_OBJECTS SQL> alter table system.myobjects row archival; 我們現(xiàn)在執(zhí)行行存檔。早于2018年7月1日的數(shù)據(jù)被視為“舊”數(shù)據(jù),需要存檔。使用ORA_ARCHIVE_ STATE=DBMS_ILM.ARCHIVESTATENAME文件名(1) 子句來實現(xiàn)這一行的存檔。 如果在執(zhí)行存檔之后查詢表,我們會看到它現(xiàn)在顯示表只有310行,而不是71710行! SQL> select count(*) from system.myobjects; 驗證摘錄是否捕獲了此更新語句 GGSCI (host01.localdomain as c##oggadmin@ORCLCDB/PDB1) 19> stats ext1 latest 請注意,復制也在目標表上執(zhí)行,并且在目標表上啟用了行存檔,我們只看到表中的310行。 GGSCI (host02.localdomain) 10> stats rep1 latest
2 (position_name)
3 values
4 ('President');
1 row created.
SQL> insert into hr.job_positions
2 (position_name)
3 values
4 ('Vice-President');
1 row created.
SQL> insert into hr.job_positions
2 (position_name)
3 values
4 ('Manager');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from hr.job_positions;
POSITION_ID POSITION_NAME
----------- --------------------
1 President
2 Vice-President
3 Manager
Sending STATS request to EXTRACT EXT1 ...
Start of Statistics at 2019-01-16 12:01:19.
Output to ./dirdat/ogg1/lt:
Extracting from PDB1.HR.JOB_POSITIONS to PDB1.HR.JOB_POSITIONS:
*** Latest statistics since 2019-01-16 12:00:15 ***
Total inserts 3.00
Total updates 0.00
Total deletes 0.00
Total discards 0.00
Total operations 3.00
End of Statistics.
POSITION_ID POSITION_NAME
----------- --------------------
1 President
2 Vice-President
3 Manager
Table altered.
SQL> select distinct ora_archive_state from system.myobjects;
ORA_ARCHIVE_STATE
--------------------------------------------------------------------------------
0
COUNT(*)
----------
71710
SQL> select count(*) from system.myobjects where created < '01-JUL-18';
COUNT(*)
----------
71400
SQL> select count(*) from system.myobjects where created > '01-JUL-18';
COUNT(*)
----------
310
SQL> update system.myobjects
set ORA_ARCHIVE_STATE=DBMS_ILM.ARCHIVESTATENAME(1)
where created commit;
Commit complete.
SQL> select count(*) from system.myobjects;
COUNT(*)
----------
310
Sending STATS request to EXTRACT EXT1 ...
Start of Statistics at 2019-01-19 10:37:54.
Output to ./dirdat/lt:
Extracting from PDB1.SYSTEM.MYOBJECTS to PDB1.SYSTEM.MYOBJECTS:
*** Latest statistics since 2019-01-19 10:26:27 ***
Total inserts 71710.00
Total updates 71400.00
Total deletes 0.00
Total discards 0.00
Total operations 143110.00
End of Statistics.
Sending STATS request to REPLICAT REP1 ...
Start of Statistics at 2019-01-19 10:43:44.
Integrated Replicat Statistics:
Total transactions 2.00
Redirected 0.00
Replicated procedures 0.00
DDL operations 0.00
Stored procedures 0.00
Datatype functionality 0.00
Event actions 0.00
Direct transactions ratio 0.00%
Replicating from PDB1.SYSTEM.MYOBJECTS to PDB2.SYSTEM.MYOBJECTS:
*** Latest statistics since 2019-01-19 10:43:07 ***
Total inserts 71710.00
Total updates 71400.00
Total deletes 0.00
Total discards 0.00
Total operations 143110.00
End of Statistics.
SQL> select count(*) from system.myobjects;
COUNT(*)
----------
310