置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
创始人
2024-05-27 19:17:21
0

置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天
置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论90天

博主所在单位目前使用Oracle GoldenGate将各个业务生产库汇聚到一起做数仓实时ODS平台,源端库可能涉及Oracle、Mysql、达梦、Guassdb库。为了做增量etl以及记录每条数据的变更历史:

  • 我们采用异构同步,即源端同步过来的表在ODS新增了一个etltime字段,用来记录当前数据变更时间。
  • 为了记录数据的事务变更历史记录,我们将数据的变更记录映射同步到一张tab_name_audit表中。
  • 为了防止源端业务库误删数据,我们将被删除的数据映射同步到一张tab_name_his表中。
  • 原表映射到ods后还是正常的映射同步dml操作。

至于以上方式是怎么实现的,我这里给大家在本地电脑做一次模拟。至于GoldenGate如何安装,请看博主其他相关文章,这里就不赘述了!!!


一、GoldenGate简介

在这里插入图片描述

GoldenGate公司成立于1995年的美国加州旧金山, 它的名称源自旧金山闻名于世的金门大桥。
该公司于2009年9月被Oracle公司收购,在此之前Oracle和GoldGate公司就有了长达超过10年的合作关系。
GoldenGate几乎支持市面上流行的所有主流的操作系统平台和数据库。
在不同的平台生成的core文件,有不同的本地堆栈跟踪工具来分析。
在这里插入图片描述

GoldenGate的模式包括下图中描述的几种,其中“一对一”是GoldenGate最简单的一种模式,也是最常用的模式。
在这里插入图片描述
GoldenGate的大致工作原理:
在这里插入图片描述

GoldenGate能够解决如下不同的需求
在这里插入图片描述
在这里插入图片描述
好了,大致介绍就说到这里,相信需要本篇文章帮助的网友们,对以上肯定都很熟悉了!!!直接奔主题!


二、环境简介

1、本实验用到的OGG版本

[oracle@OGG ogg11]$ ./ggsci -vOracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

2、实验中使用的重点参数

下面仅列出来两个重要参数,其他参数请参考官方文档或本博主的另一篇介绍ogg三大进程参数的博客!

--------------------NOCOMPRESSDELETES

COMPRESSDELETES | NOCOMPRESSDELETES Valid for Extract Use the
COMPRESSDELETES and NOCOMPRESSDELETES parameters to control the way
columns are written to the trail record for delete operations.
COMPRESSDELETES, the default, causes Extract to write only the primary
key to the trail for delete operations. The key provides enough
information to delete the correct target record, while restricting the
amount of data that must be processed. NOCOMPRESSDELETES sends all of
the columns to the trail. This becomes the default when a table
definition does not include a primary key or unique index. If a
substitute key was defined with the KEYCOLS option of TABLE, then
those columns are written to the trail, whether or not a real key was
defined. NOCOMPRESSDELETES also is required when using the Conflict
Detection and Resolution (CDR) feature for a DB2 database on any of
the platforms that are supported by Oracle GoldenGate. For more
information about CDR, see the Oracle GoldenGate Windows and UNIX
Administrator’s Guide. COMPRESSDELETES and NOCOMPRESSDELETES can be
used globally for all TABLE statements in the parameter file, or they
can be used as on-off switches for individual TABLE statements. These
parameters do not affect data pumps. Default COMPRESSDELETES Syntax
COMPRESSDELETES | NOCOMPRESSDELETES

------------------------INSERTDELETES INSERTDELETES | NOINSERTDELETES Valid for Replicat Use the INSERTDELETES and NOINSERTDELETES
parameters to control whether or not Oracle GoldenGate converts source
delete operations to insert operations on the target database. The
parameters are table-specific. One parameter remains in effect for all
subsequent MAP statements, until the other parameter is encountered.
When using INSERTDELETES, use the NOCOMPRESSDELETES parameter so that
Extract does not compress deletes. Default NOINSERTDELETES Syntax
INSERTDELETES | NOINSERTDELETES

测试开始前使用根据生产配置提前配置好的正常同步的ogg环境,环境部署忽略,目的端配置在原有的一对三模式下增加一个对只存被删除的整条记录的
历史表tablename_DEL(被删除记录的完整记录+操作类型和被删除时间以及是前映像还是后映像)来测试

二、源库创建测试用表

1、创建有物理主键表

CREATE TABLE DEPT
(DEPTNO NUMBER(2) NOT NULL,DNAME  VARCHAR2(14),LOC    VARCHAR2(13)
)
TABLESPACE USERSPCTFREE 10INITRANS 1MAXTRANS 255STORAGE(INITIAL 64KNEXT 1MMINEXTENTS 1MAXEXTENTS UNLIMITED);
-- CREATE/RECREATE PRIMARY, UNIQUE AND FOREIGN KEY CONSTRAINTS 
ALTER TABLE DEPTADD CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO)USING INDEX TABLESPACE USERSPCTFREE 10INITRANS 2MAXTRANS 255STORAGE(INITIAL 64KNEXT 1MMINEXTENTS 1MAXEXTENTS UNLIMITED);
BEGIN 
FOR I IN 1..10 
LOOP
INSERT INTO DEPT VALUES(I,'A','B');
END LOOP;
COMMIT;
END;
/

2、创建无物理主键有逻辑主键表(逻辑主键:EMPNO,ENAME)

CREATE TABLE NOPK_TAB 
(EMPNO NUMBER(6),
ENAME VARCHAR2(20),
SAL  NUMBER(7,2),
DEPTNO NUMBER(4)
);INSERT INTO NOPK_TAB VALUES(1110,'ZHAO',100,10);
INSERT INTO NOPK_TAB VALUES(1110,'YAN',200,20);
INSERT INTO NOPK_TAB VALUES(1111,'YAN',100,10);
INSERT INTO NOPK_TAB VALUES(1111,'DONG',100,30);

三、目标端创建审计表和只存被删除记录历史表

1、创建审计表

CREATE TABLE SCOTT.NOPK_TAB_AUDIT
(
EMPNO  NUMBER(6),
ENAME VARCHAR2(20),CSN        NUMBER,OPTIME    TIMESTAMP(6),OPTYPE    VARCHAR2(20),INSERTTIME TIMESTAMP(6),CURDATE    TIMESTAMP(6)
);
CREATE TABLE DEPT_AUDIT
(DEPTNO    NUMBER(2),CSN        NUMBER,OPTIME    TIMESTAMP(6),OPTYPE    VARCHAR2(20),INSERTTIME TIMESTAMP(6),CURDATE    TIMESTAMP(6)
)

2、创建只存删除记录的历史表

CREATE TABLE DEPT_DEL
(DEPTNO      NUMBER(2),DNAME        VARCHAR2(14),LOC          VARCHAR2(13),BEFORE_AFTER VARCHAR2(20),DEL_DATE    TIMESTAMP,OP_FLAG      VARCHAR2(20)
);
CREATE TABLE NOPK_TAB_DEL 
(EMPNO        NUMBER(6),ENAME        VARCHAR2(20),SAL          NUMBER(7,2),DEPTNO      NUMBER(4),BEFORE_AFTER VARCHAR2(20),DEL_DATE    TIMESTAMP,OP_FLAG      VARCHAR2(20)
);

四、停止抽取进程和投递进程

stop er *

五、添加附加日志

dblogin userid ogg password ogg
add trandata SCOTT.dept
add trandata SCOTT.NOPK_TAB,nokey,cols(EMPNO,ENAME)

六、配置抽取进程

extract e_sc
userid ogg,password ogg
setenv(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
setenv(ORACLE_SID="orcl")
reportcount every 10 minutes,rate
numfiles 5000
discardfile ./dirrpt/e_sc.dsc,append,megabytes 1000
warnlongtrans 2h,checkinterval 3m
exttrail ./dirdat/sc
threadoptions maxcommitpropagationdelay 60000
dboptions allowunusedcolumn
tranlogoptions archivedlogonly
tranlogoptions altarchivelogdest primary /u01/archivelog
TRANLOGOPTIONS ALTARCHIVEDLOGFORMAT %t_%s_%r.dbf
dynamicresolution
ddl include mapped
ddloptions addtrandata,report
notcpsourcetimer
nocompressupdates
--fetchoptions nousesnapshot
fetchoptions USEROWID
--GETUPDATEBEFORES
NOCOMPRESSDELETES
----------scott.EMP
table SCOTT.EMP,tokens(
TKN-CSN = @GETENV("TRANSACTION", "CSN"),
TKN-COMMIT-TS = @GETENV ("GGHEADER", "COMMITTIMESTAMP"),
TKN-OP-TYPE = @GETENV ("GGHEADER", "OPTYPE")
);
----------SCOTT.DEPT
table SCOTT.DEPT,tokens(
TKN-CSN = @GETENV("TRANSACTION", "CSN"),
TKN-COMMIT-TS = @GETENV ("GGHEADER", "COMMITTIMESTAMP"),
TKN-OP-TYPE = @GETENV ("GGHEADER", "OPTYPE")
);
----------SCOTT.DEL
table SCOTT.DEL,tokens(
TKN-CSN = @GETENV("TRANSACTION", "CSN"),
TKN-COMMIT-TS = @GETENV ("GGHEADER", "COMMITTIMESTAMP"),
TKN-OP-TYPE = @GETENV ("GGHEADER", "OPTYPE")
);
----------SCOTT.NOPK_TAB
TABLE SCOTT.NOPK_TAB_TAB,KEYCOLS(EMPNO,ENAME),TOKENS(
TKN-CSN = @GETENV("TRANSACTION", "CSN"),
TKN-COMMIT-TS = @GETENV ("GGHEADER", "COMMITTIMESTAMP"),
TKN-OP-TYPE = @GETENV ("GGHEADER", "OPTYPE")
);

七、目标库应用进程配置

replicat r_sc2
setenv(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
userid ogg,password ogg
reportcount every 30 minutes,rate
reperror default,abend
--reperror default,DISCARD
numfiles 50000
checkpointsecs 40
assumetargetdefs
discardfile ./dirrpt/r_sc2.dsc,append,megabytes 1000
allownoopupdates
ddl &
include mapped &
exclude objname scott.*_audit &
exclude optype create &objtype 'table' &
exclude optype drop &objtype 'table' &
exclude objtype 'index' &objname SCOTT.*_his &
exclude instr 'constraint' &
---exclude instr 'null' &
exclude instr 'trigger' &
exclude instr 'rename to' &
exclude instr 'grant' &
exclude instr 'revoke' &
exclude instr 'analyze'
DDLOPTIONS MAPSESSIONSCHEMA XUM target ogg
ddloptions report
allowduptargetmap
----------DEPT
getinserts
getupdates
getdeletes
noupdatedeletes
NOINSERTDELETES
map SCOTT.DEPT,target SCOTT.DEPT;
updatedeletes
--INSERTDELETES
map SCOTT.DEPT,target SCOTT.DEPT_HIS,keycols(DEPTNO);
getinserts
ignoreupdates
ignoredeletes
map SCOTT.DEPT,target SCOTT.DEPT_AUDIT,keycols(DEPTNO),colmap(
usedefaults,
csn=@token("TKN-CSN"),
optime=@token("TKN-COMMIT-TS"),
optype=@token("TKN-OP-TYPE"),
inserttime=@token("TKN-COMMIT-TS"),
curdate=@DATENOW()
);
ignoreinserts
getupdates
getdeletes
map SCOTT.DEPT,target SCOTT.DEPT_AUDIT,keycols(DEPTNO),colmap(
usedefaults,
csn=@token("TKN-CSN"),
optime=@token("TKN-COMMIT-TS"),
optype=@token("TKN-OP-TYPE"),
curdate=@DATENOW()
),filter(@strfind(@token("TKN-OP-TYPE"),"PK UPDATE") =0);
ignoreinserts
getupdates
getdeletes
map SCOTT.DEPT,target SCOTT.DEPT_AUDIT,keycols(DEPTNO),colmap(
usedefaults,
csn=@token("TKN-CSN"),
optime=@token("TKN-COMMIT-TS"),
optype=@case(@token("TKN-OP-TYPE"),"PK UPDATE","INSERT"),
inserttime=@token("TKN-COMMIT-TS"),
curdate=@DATENOW()
),filter(@strfind(@token("TKN-OP-TYPE"),"PK UPDATE") >0),insertallrecords;
ignoreinserts
getupdates
getdeletes
map SCOTT.DEPT,target SCOTT.DEPT_AUDIT,keycols(DEPTNO),colmap(
DEPTNO=before.DEPTNO,
csn=@token("TKN-CSN"),
optime=@token("TKN-COMMIT-TS"),
optype=@case(@token("TKN-OP-TYPE"),"PK UPDATE","DELETE"),
curdate=@DATENOW()
),filter(@strfind(@token("TKN-OP-TYPE"),"PK UPDATE") >0);
ignoreinserts
ignoreupdates
getdeletes
noupdatedeletes
INSERTDELETES
MAP SCOTT.DEPT, TARGET SCOTT.DEPT_DEL,keycols(DEPTNO),colmap(
usedefaults
BEFORE_AFTER=@getenv("GGHEADER", "BEFOREAFTERINDICATOR"),
DEL_DATE=@getenv ("GGHEADER", "COMMITTIMESTAMP"),
OP_FLAG=@getenv ("GGHEADER", "OPTYPE")
);
----------NOPK_TAB
getinserts
getupdates
getdeletes
noupdatedeletes
NOINSERTDELETES
map SCOTT.NOPK_TAB,target SCOTT.NOPK_TAB,keycols(EMPNO,ENAME);
updatedeletes
map SCOTT.NOPK_TAB,target SCOTT.NOPK_TAB_HIS,keycols(EMPNO,ENAME);
getinserts
getupdates
getdeletes
map SCOTT.NOPK_TAB,target SCOTT.NOPK_TAB_AUDIT,keycols(EMPNO,ENAME),colmap(
EMPNO=@if(@strfind(@token("tkn-op-type"),"PK UPDATE")>0,before.EMPNO,EMPNO),
ENAME=@if(@strfind(@token("tkn-op-type"),"PK UPDATE")>0,before.ENAME,ENAME)
csn=@token("tkn-csn"),
optime=@token("tkn-commit-ts"),
optype=@if(@strfind(@token("tkn-op-type"),"PK UPDATE")>0,"DELETE",@token("tkn-op-type")),
inserttime=@eval(@strfind(@token("tkn-op-type"),"INSERT")>0,@token("tkn-commit-ts")),
curdate=@DATENOW()
);
ignoreinserts
getupdates
ignoredeletes
map SCOTT.NOPK_TAB,target SCOTT.NOPK_TAB_AUDIT,keycols(EMPNO,ENAME),colmap(
usedefaults,
csn=@token("tkn-csn"),
optime=@token("tkn-commit-ts"),
optype=@case(@token("tkn-op-type"),"PK UPDATE","INSERT"),
inserttime=@token("tkn-commit-ts"),
curdate=@DATENOW()
),filter(@strfind(@token("tkn-op-type"),"PK UPDATE") >0),insertallrecords;
ignoreinserts
ignoreupdates
getdeletes
noupdatedeletes
INSERTDELETES
MAP SCOTT.NOPK_TAB, TARGET SCOTT.NOPK_TAB_DEL,keycols(EMPNO,ENAME),colmap(
usedefaults,
BEFORE_AFTER=@getenv("GGHEADER", "BEFOREAFTERINDICATOR"),
DEL_DATE=@getenv ("GGHEADER", "COMMITTIMESTAMP"),
OP_FLAG=@getenv ("GGHEADER", "OPTYPE")
);

八、启动抽取进程和投递进程

start er *

九、从源端倒数到目的端并启动应用进程

省略

十、验证是否能够只存被删除的数据完整记录

验证数据是否能够正常同步
源端分别进行插入更新删除操作:

------------------------------------------------有物理主键表:
SQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 a              b2 a              b3 a              b4 a              b5 a              b6 a              b7 a              b8 a              b9 a              b10 a              b10 rows selectedSQL> insert into dept values(11,'a','b');1 row insertedSQL>delete from dept where deptno=10;1 row deletedSQL> update dept set dname='aaa'where deptno=9;1 row updatedSQL> commit;Commit completeSQL> alter system switch logfile;System alteredSQL> /System alteredSQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 a              b2 a              b3 a              b4 a              b5 a              b6 a              b7 a              b8 a              b9 aaa            b11 a              b10 rows selected-----------------------------在目的端查看:
SQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B2 A              B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B11 a              b10 rows selectedSQL> select * from dept_audit;DEPTNO        CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------ ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  2    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  3    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  4    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  5    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  6    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  7    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  8    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  9    1603672 11-2月 -18 02.30.35.000000 下午                                                  SQL COMPUPDATE      11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午10    1603672 11-2月 -18 02.30.35.000000 下午                                                  DELETE              11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午11    1603672 11-2月 -18 02.30.35.000000 下午                                                  INSERT              11-2月 -18 02.30.35.000000 下午                                                  11-2月 -18 02.30.56.000000 下午11 rows selectedSQL> select * from dept_his;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B2 A              B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B10 a              b11 a              b11 rows selectedSQL> select * from dept_del;DEPTNO DNAME          LOC          BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------ -------------- ------------- -------------------- -------------------------------------------------------------------------------- --------------------10 a              b            BEFORE              11-2月 -18 02.30.35.015854 下午                                                  DELETE

发现在源端执行的delete操作在目的端原来的一对三配置的表中表现正常,在dept_del表中只保留了delete操作对应的那条记录的完整记录以及操作类型和时间。
无物理主键有逻辑主键表验证是否能够正常同步

------源端操作
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1110 zhao                    100.00    101110 yan                    200.00    201111 yan                    100.00    101111 dong                    100.00    30SQL> insert into nopk_tab values(1112,'test',300,20);1 row insertedSQL> delete from nopk_tab where empno=1111 and ename='dong';1 row deletedSQL> update nopk_tab set sal=400 where empno=1110 and ename='zhao';1 row updatedSQL> commit;Commit completeSQL> alter system switch logfile;System alteredSQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1110 zhao                    400.00    101110 yan                    200.00    201111 yan                    100.00    101112 test                    300.00    20----------------------------------------------------在目标端查看SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1110 yan                    200.00    201111 yan                    100.00    101110 zhao                    400.00    101112 test                    300.00    20SQL> select * from nopk_tab_audit;EMPNO ENAME                      CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------- -------------------- ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1110 yan                    1521438 11-2月 -18 03.01.24.000000 下午                                                  INITIAL              11-2月 -18 03.01.24.000000 下午                                                  1111 yan                    1521438 11-2月 -18 03.01.24.000000 下午                                                  INITIAL              11-2月 -18 03.01.24.000000 下午                                                  1111 dong                    1606066 11-2月 -18 03.05.59.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1110 zhao                    1606066 11-2月 -18 03.05.59.000000 下午                                                  SQL COMPUPDATE      11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1112 test                    1606066 11-2月 -18 03.05.59.000000 下午                                                  INSERT              11-2月 -18 03.05.59.000000 下午                                                  11-2月 -18 03.06.11.000000 下午SQL> select * from nopk_tab_HIS;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1110 zhao                    400.00    101110 yan                    200.00    201111 yan                    100.00    101111 dong                    100.00    301112 test                    300.00    20SQL> select * from nopk_tab_del;EMPNO ENAME                      SAL DEPTNO BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------- -------------------- --------- ------ -------------------- -------------------------------------------------------------------------------- --------------------1111 dong                    100.00    30 BEFORE              11-2月 -18 03.05.59.015810 下午                                                  DELETE

发生pkupdate操作时:

-----------修改主键+某个列:有物理主键表:
SQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 a              b2 a              b3 a              b4 a              b5 a              b6 a              b7 a              b8 a              b9 aaa            b11 a              b10 rows selectedSQL> update dept set deptno=22, dname='b' where deptno=2;1 row updatedSQL> commit;Commit completeSQL> alter system switch logfile;System alteredSQL> alter system switch logfile;System altered
在目的端查看:
SQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B22 b              B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B11 a              b10 rows selectedSQL> select * from dept_audit;DEPTNO        CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------ ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  2    1606224 11-2月 -18 03.10.39.000000 下午                                                  DELETE              11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 03.11.09.000000 下午3    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  4    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  5    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  6    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  7    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  8    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  9    1603672 11-2月 -18 02.30.35.000000 下午                                                  SQL COMPUPDATE      11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午10    1603672 11-2月 -18 02.30.35.000000 下午                                                  DELETE              11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午11    1603672 11-2月 -18 02.30.35.000000 下午                                                  INSERT              11-2月 -18 02.30.35.000000 下午                                                  11-2月 -18 02.30.56.000000 下午22    1606224 11-2月 -18 03.10.39.000000 下午                                                  INSERT              11-2月 -18 03.10.39.000000 下午                                                  11-2月 -18 03.11.09.000000 下午12 rows selectedSQL> select * from dept_his;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B22 b              B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B10 a              b11 a              b11 rows selectedSQL> select * from dept_del;DEPTNO DNAME          LOC          BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------ -------------- ------------- -------------------- -------------------------------------------------------------------------------- --------------------10 a              b            BEFORE              11-2月 -18 02.30.35.015854 下午                                                  DELETE挖掘trail日志,确认是pkupdate操作:
Logdump 301 >n
TokenID x47 'G' Record Header    Info x01  Length  235 
TokenID x48 'H' GHDR            Info x00  Length  45 
4504 0041 0027 73ff 02f2 8b1d ea2d c765 0000 0000 | E..A.'s......-.e....  
0000 9010 0000 0000 0352 0000 0001 5343 4f54 542e | .........R....SCOTT.  
4445 5054 00                                      | DEPT.  
TokenID x44 'D' Data            Info x00  Length  39 
TokenID x54 'T' GGS Tokens      Info x00  Length  48 
TokenID x55 'U' User Tokens      Info x00  Length  79 
TokenID x5a 'Z' Record Trailer  Info x01  Length  235 
___________________________________________________________________ 
Hdr-Ind    :    E  (x45)    Partition  :    .  (x04)  
UndoFlag  :    .  (x00)    BeforeAfter:    A  (x41)  
RecLength  :    39  (x0027)  IO Time    : 2018/02/11 15:10:39.015.781  
IOType    :  115  (x73)    OrigNode  :  255  (xff) 
TransInd  :    .  (x03)    FormatType :    R  (x52) 
SyskeyLen  :    0  (x00)    Incomplete :    .  (x00) 
AuditRBA  :          0      AuditPos  : 36880 
Continued  :    N  (x00)    RecCount  :    1  (x01) 2018/02/11 15:10:39.015.781 GGSPKUpdate          Len    39 RBA 6284 
Name: SCOTT.DEPT 
After  Image:                                            Partition 4  GU s  
000e 0000 000a 0000 0000 0000 0000 0002 0000 000a | ....................  
0000 0000 0000 0000 0016 0001 0005 0000 0001 62  | ..................b  
Before Image          Len    16 (x00000010) 
KeyLen    14 (x0000000e) 
KeyCol    0 (x0000), Len    10 (x000a)  
0000 0000 0000 0000 0002                          | ..........  After Image          Len    23 (x00000017) 
Column    0 (x0000), Len    10 (x000a)  
0000 0000 0000 0000 0016                          | ..........  
Column    1 (x0001), Len    5 (x0005)  
0000 0001 62                                      | ....b  User tokens:  79 bytes 
TKN-CSN            : 1606224 
TKN-COMMIT-TS      : 2018-02-11 15:10:39.000000 
TKN-OP-TYPE        : PK UPDATE GGS tokens: 
TokenID x52 'R' ORAROWID        Info x00  Length  20 
4141 4156 5243 4141 4541 4141 4143 4441 4142 0001 | AAAVRCAAEAAAACDAAB..  
TokenID x4c 'L' LOGCSN          Info x00  Length    7 
3136 3036 3232 34                                | 1606224  
TokenID x36 '6' TRANID          Info x00  Length    9 
332e 3333 2e31 3335 35                            | 3.33.1355  

只修改主键列同上pkupdate操作,结果一致。

-------------------无物理主键表修改逻辑主键:
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1110 zhao                    400.00    101110 yan                    200.00    201111 yan                    100.00    101112 test                    300.00    20SQL> update nopk_tab set empno=1222,ename='zhaozhao' where empno=1110 and ename='zhao';1 row updatedSQL> commit;Commit completeSQL> alter system switch logfile;System altered
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao                400.00    101110 yan                    200.00    201111 yan                    100.00    101112 test                    300.00    20-----------查看目的端
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1110 yan                    200.00    201111 yan                    100.00    101222 zhaozhao                400.00    101112 test                    300.00    20SQL> select * from nopk_tab_audit;EMPNO ENAME                      CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------- -------------------- ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1110 yan                    1521438 11-2月 -18 03.01.24.000000 下午                                                  INITIAL              11-2月 -18 03.01.24.000000 下午                                                  1111 yan                    1521438 11-2月 -18 03.01.24.000000 下午                                                  INITIAL              11-2月 -18 03.01.24.000000 下午                                                  1111 dong                    1606066 11-2月 -18 03.05.59.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1110 zhao                    1606635 11-2月 -18 03.20.04.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.20.10.000000 下午1112 test                    1606066 11-2月 -18 03.05.59.000000 下午                                                  INSERT              11-2月 -18 03.05.59.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1222 zhaozhao                1606635 11-2月 -18 03.20.04.000000 下午                                                  INSERT              11-2月 -18 03.20.04.000000 下午                                                  11-2月 -18 03.20.10.000000 下午6 rows selectedSQL> select * from nopk_tab_HIS;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao                400.00    101110 yan                    200.00    201111 yan                    100.00    101111 dong                    100.00    301112 test                    300.00    20SQL> select * from nopk_tab_DEL;EMPNO ENAME                      SAL DEPTNO BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------- -------------------- --------- ------ -------------------- -------------------------------------------------------------------------------- --------------------1111 dong                    100.00    30 BEFORE              11-2月 -18 03.05.59.015810 下午                                                  DELETE挖掘trail日志:
Logdump 306 >n
TokenID x47 'G' Record Header    Info x01  Length  258 
TokenID x48 'H' GHDR            Info x00  Length  49 
4504 0041 003a 73ff 02f2 8b1e 0bda fed5 0000 0000 | E..A.:s.............  
0000 9410 0000 0000 0352 0000 0001 5343 4f54 542e | .........R....SCOTT.  
4e4f 504b 5f54 4142 00                            | NOPK_TAB.  
TokenID x44 'D' Data            Info x00  Length  58 
TokenID x54 'T' GGS Tokens      Info x00  Length  48 
TokenID x55 'U' User Tokens      Info x00  Length  79 
TokenID x5a 'Z' Record Trailer  Info x01  Length  258 
___________________________________________________________________ 
Hdr-Ind    :    E  (x45)    Partition  :    .  (x04)  
UndoFlag  :    .  (x00)    BeforeAfter:    A  (x41)  
RecLength  :    58  (x003a)  IO Time    : 2018/02/11 15:20:04.015.829  
IOType    :  115  (x73)    OrigNode  :  255  (xff) 
TransInd  :    .  (x03)    FormatType :    R  (x52) 
SyskeyLen  :    0  (x00)    Incomplete :    .  (x00) 
AuditRBA  :          0      AuditPos  : 37904 
Continued  :    N  (x00)    RecCount  :    1  (x01) 2018/02/11 15:20:04.015.829 GGSPKUpdate          Len    58 RBA 6758 
Name: SCOTT.NOPK_TAB 
After  Image:                                            Partition 4  GU s  
001a 0000 000a 0000 0000 0000 0000 0456 0001 0008 | ...............V....  
0000 0004 7a68 616f 0000 000a 0000 0000 0000 0000 | ....zhao............  
04c6 0001 000c 0000 0008 7a68 616f 7a68 616f      | ..........zhaozhao  
Before Image          Len    28 (x0000001c) 
KeyLen    26 (x0000001a) 
KeyCol    0 (x0000), Len    10 (x000a)  
0000 0000 0000 0000 0456                          | .........V  
KeyCol    1 (x0001), Len    8 (x0008)  
0000 0004 7a68 616f                              | ....zhao  After Image          Len    30 (x0000001e) 
Column    0 (x0000), Len    10 (x000a)  
0000 0000 0000 0000 04c6                          | ..........  
Column    1 (x0001), Len    12 (x000c)  
0000 0008 7a68 616f 7a68 616f                    | ....zhaozhao  User tokens:  79 bytes 
TKN-CSN            : 1606635 
TKN-COMMIT-TS      : 2018-02-11 15:20:04.000000 
TKN-OP-TYPE        : PK UPDATE GGS tokens: 
TokenID x52 'R' ORAROWID        Info x00  Length  20 
4141 4156 7379 4141 4541 4141 4149 6c41 4141 0001 | AAAVsyAAEAAAAIlAAA..  
TokenID x4c 'L' LOGCSN          Info x00  Length    7 
3136 3036 3633 35                                | 1606635  
TokenID x36 '6' TRANID          Info x00  Length    9 
322e 3230 2e31 3335 39                            | 2.20.1359  -------------------无物理主键表修改逻辑主键+非逻辑主键列:SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao                400.00    101110 yan                    200.00    201111 yan                    100.00    101112 test                    300.00    20SQL> update nopk_tab set empno=3333,ename='yanyan',sal=500 where empno=1110 and ename='yan';1 row updatedSQL> commit;Commit completeSQL> alter system switch logfile;System alteredSQL> alter system switch logfile;System alteredSQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao                400.00    103333 yanyan                  500.00    201111 yan                    100.00    101112 test                    300.00    20
目的端查看SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------3333 yanyan                  500.00    201111 yan                    100.00    101222 zhaozhao                400.00    101112 test                    300.00    20SQL> select * from nopk_tab_audit;EMPNO ENAME                      CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------- -------------------- ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1110 yan                    1606931 11-2月 -18 03.24.32.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.24.38.000000 下午1111 yan                    1521438 11-2月 -18 03.01.24.000000 下午                                                  INITIAL              11-2月 -18 03.01.24.000000 下午                                                  1111 dong                    1606066 11-2月 -18 03.05.59.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1110 zhao                    1606635 11-2月 -18 03.20.04.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.20.10.000000 下午3333 yanyan                  1606931 11-2月 -18 03.24.32.000000 下午                                                  INSERT              11-2月 -18 03.24.32.000000 下午                                                  11-2月 -18 03.24.38.000000 下午1112 test                    1606066 11-2月 -18 03.05.59.000000 下午                                                  INSERT              11-2月 -18 03.05.59.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1222 zhaozhao                1606635 11-2月 -18 03.20.04.000000 下午                                                  INSERT              11-2月 -18 03.20.04.000000 下午                                                  11-2月 -18 03.20.10.000000 下午7 rows selectedSQL> select * from nopk_tab_HIS;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao                400.00    103333 yanyan                  500.00    201111 yan                    100.00    101111 dong                    100.00    301112 test                    300.00    20SQL> select * from nopk_tab_DEL;EMPNO ENAME                      SAL DEPTNO BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------- -------------------- --------- ------ -------------------- -------------------------------------------------------------------------------- --------------------1111 dong                    100.00    30 BEFORE              11-2月 -18 03.05.59.015810 下午                                                  DELETE
挖掘trail日志,确实是pkupdate操作:
Logdump 308 >n  
TokenID x47 'G' Record Header    Info x01  Length  268 
TokenID x48 'H' GHDR            Info x00  Length  49 
4504 0041 0045 73ff 02f2 8b1e 1bd4 59ab 0000 0000 | E..A.Es.......Y.....  
0003 c610 0000 0000 0352 0000 0001 5343 4f54 542e | .........R....SCOTT.  
4e4f 504b 5f54 4142 00                            | NOPK_TAB.  
TokenID x44 'D' Data            Info x00  Length  69 
TokenID x54 'T' GGS Tokens      Info x00  Length  47 
TokenID x55 'U' User Tokens      Info x00  Length  79 
TokenID x5a 'Z' Record Trailer  Info x01  Length  268 
___________________________________________________________________ 
Hdr-Ind    :    E  (x45)    Partition  :    .  (x04)  
UndoFlag  :    .  (x00)    BeforeAfter:    A  (x41)  
RecLength  :    69  (x0045)  IO Time    : 2018/02/11 15:24:32.015.787  
IOType    :  115  (x73)    OrigNode  :  255  (xff) 
TransInd  :    .  (x03)    FormatType :    R  (x52) 
SyskeyLen  :    0  (x00)    Incomplete :    .  (x00) 
AuditRBA  :          0      AuditPos  : 247312 
Continued  :    N  (x00)    RecCount  :    1  (x01) 2018/02/11 15:24:32.015.787 GGSPKUpdate          Len    69 RBA 7016 
Name: SCOTT.NOPK_TAB 
After  Image:                                            Partition 4  GU s  
0019 0000 000a 0000 0000 0000 0000 0456 0001 0007 | ...............V....  
0000 0003 7961 6e00 0000 0a00 0000 0000 0000 000d | ....yan.............  
0500 0100 0a00 0000 0679 616e 7961 6e00 0200 0a00 | .........yanyan.....  
0000 0000 0000 00c3 50                            | ........P  
Before Image          Len    27 (x0000001b) 
KeyLen    25 (x00000019) 
KeyCol    0 (x0000), Len    10 (x000a)  
0000 0000 0000 0000 0456                          | .........V  
KeyCol    1 (x0001), Len    7 (x0007)  
0000 0003 7961 6e                                | ....yan  After Image          Len    42 (x0000002a) 
Column    0 (x0000), Len    10 (x000a)  
0000 0000 0000 0000 0d05                          | ..........  
Column    1 (x0001), Len    10 (x000a)  
0000 0006 7961 6e79 616e                          | ....yanyan  
Column    2 (x0002), Len    10 (x000a)  
0000 0000 0000 0000 c350                          | .........P  User tokens:  79 bytes 
TKN-CSN            : 1606931 
TKN-COMMIT-TS      : 2018-02-11 15:24:32.000000 
TKN-OP-TYPE        : PK UPDATE GGS tokens: 
TokenID x52 'R' ORAROWID        Info x00  Length  20 
4141 4156 7379 4141 4541 4141 4149 6c41 4142 0001 | AAAVsyAAEAAAAIlAAB..  
TokenID x4c 'L' LOGCSN          Info x00  Length    7 
3136 3036 3933 31                                | 1606931  
TokenID x36 '6' TRANID          Info x00  Length    8 
322e 362e 3133 3630                              | 2.6.1360  

上面操作证明对DEL表的配置确实可以捕获到源端delelte操作的记录对应的完整记录并插入表中,接下来测试当同一个主键号多次插入删除,DEL表会不会累积历史操作:

-----------------------------------------------------测试同一条记录连续插入删除多次,在DEL表中是否会存在多条相同记录:
----------------在有物理主键表测试:
SQL> insert into dept values(33,'a','a');1 row insertedSQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 a              b23 bbbbb          b3 a              b4 a              b5 a              b6 a              b7 a              b8 a              b9 aaa            b11 a              b33 a              a11 rows selectedSQL> commit;Commit completeSQL> alter system switch logfile;System altered
目的端查看:
SQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B23 bbbbb          B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B11 a              b33 a              a11 rows selected
同步过来了,源端再执行删除:SQL> delete from dept where deptno=33;1 row deletedSQL> commit;Commit completeSQL> alter system switch logfile;System altered
再来目的端查看:
SQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B23 bbbbb          B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B11 a              b10 rows selectedSQL> select * from dept_audit;DEPTNO        CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------ ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  2    1606224 11-2月 -18 03.10.39.000000 下午                                                  DELETE              11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 03.11.09.000000 下午3    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  4    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  5    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  6    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  7    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  8    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  9    1603672 11-2月 -18 02.30.35.000000 下午                                                  SQL COMPUPDATE      11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午10    1603672 11-2月 -18 02.30.35.000000 下午                                                  DELETE              11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午11    1603672 11-2月 -18 02.30.35.000000 下午                                                  INSERT              11-2月 -18 02.30.35.000000 下午                                                  11-2月 -18 02.30.56.000000 下午22    1606528 11-2月 -18 03.17.25.000000 下午                                                  DELETE              11-2月 -18 03.10.39.000000 下午                                                  11-2月 -18 03.17.31.000000 下午23    1606528 11-2月 -18 03.17.25.000000 下午                                                  INSERT              11-2月 -18 03.17.25.000000 下午                                                  11-2月 -18 03.17.31.000000 下午33    1607183 11-2月 -18 03.29.38.000000 下午                                                  DELETE              11-2月 -18 03.28.15.000000 下午                                                  11-2月 -18 03.29.45.000000 下午14 rows selectedSQL> select * from dept_his;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B23 bbbbb          B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B10 a              b11 a              b33 a              a12 rows selectedSQL> select * from dept_del;DEPTNO DNAME          LOC          BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------ -------------- ------------- -------------------- -------------------------------------------------------------------------------- --------------------10 a              b            BEFORE              11-2月 -18 02.30.35.015854 下午                                                  DELETE33 a              a            BEFORE              11-2月 -18 03.29.38.015754 下午                                                  DELETE
再在源端进行插入同一记录,在删除:
SQL> insert into dept values(33,'a','a');1 row insertedSQL> commit;Commit completeSQL> delete from dept where deptno=33;1 row deletedSQL> commit;Commit completeSQL> alter system switch logfile;System altered在目睹端查看:
SQL> select * from dept;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B23 bbbbb          B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B11 a              b10 rows selectedSQL> select * from dept_audit;DEPTNO        CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------ ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  2    1606224 11-2月 -18 03.10.39.000000 下午                                                  DELETE              11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 03.11.09.000000 下午3    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  4    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  5    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  6    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  7    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  8    1521438 11-2月 -18 02.24.46.000000 下午                                                  INITIAL              11-2月 -18 02.24.46.000000 下午                                                  9    1603672 11-2月 -18 02.30.35.000000 下午                                                  SQL COMPUPDATE      11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午10    1603672 11-2月 -18 02.30.35.000000 下午                                                  DELETE              11-2月 -18 02.24.46.000000 下午                                                  11-2月 -18 02.30.56.000000 下午11    1603672 11-2月 -18 02.30.35.000000 下午                                                  INSERT              11-2月 -18 02.30.35.000000 下午                                                  11-2月 -18 02.30.56.000000 下午22    1606528 11-2月 -18 03.17.25.000000 下午                                                  DELETE              11-2月 -18 03.10.39.000000 下午                                                  11-2月 -18 03.17.31.000000 下午23    1606528 11-2月 -18 03.17.25.000000 下午                                                  INSERT              11-2月 -18 03.17.25.000000 下午                                                  11-2月 -18 03.17.31.000000 下午33    1607249 11-2月 -18 03.31.06.000000 下午                                                  DELETE              11-2月 -18 03.28.15.000000 下午                                                  11-2月 -18 03.31.14.000000 下午33    1607246 11-2月 -18 03.31.01.000000 下午                                                  INSERT              11-2月 -18 03.31.01.000000 下午                                                  11-2月 -18 03.31.14.000000 下午15 rows selectedSQL> select * from dept_his;DEPTNO DNAME          LOC
------ -------------- -------------1 A              B23 bbbbb          B3 A              B4 A              B5 A              B6 A              B7 A              B8 A              B9 aaa            B10 a              b11 a              b33 a              a33 a              a13 rows selectedSQL> select * from dept_del;DEPTNO DNAME          LOC          BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------ -------------- ------------- -------------------- -------------------------------------------------------------------------------- --------------------10 a              b            BEFORE              11-2月 -18 02.30.35.015854 下午                                                  DELETE33 a              a            BEFORE              11-2月 -18 03.29.38.015754 下午                                                  DELETE33 a              a            BEFORE              11-2月 -18 03.31.06.015751 下午                                                  DELETE

发现是会正常保存的。接下来测试无物理主键的:

-----源端进行如下操作:
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao                400.00    103333 yanyan                  500.00    201111 yan                    100.00    101112 test                    300.00    20SQL> insert into nopk_tab values(4444,'a',300,10);1 row insertedSQL> commit;Commit completeSQL> delete from nopk_tab where empno=4444;1 row deletedSQL> commit;Commit completeSQL> insert into nopk_tab values(4444,'a',300,10);1 row insertedSQL> commit;Commit completeSQL> delete from nopk_tab where empno=4444;1 row deletedSQL> commit;Commit completeSQL> alter system switch logfile;System altered----------目的端查看:
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------3333 yanyan                  500.00    201111 yan                    100.00    101222 zhaozhao                400.00    101112 test                    300.00    20SQL> select * from nopk_tab_audit;EMPNO ENAME                      CSN OPTIME                                                                          OPTYPE              INSERTTIME                                                                      CURDATE
------- -------------------- ---------- -------------------------------------------------------------------------------- -------------------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------1110 yan                    1606931 11-2月 -18 03.24.32.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.24.38.000000 下午1111 yan                    1521438 11-2月 -18 03.01.24.000000 下午                                                  INITIAL              11-2月 -18 03.01.24.000000 下午                                                  1111 dong                    1606066 11-2月 -18 03.05.59.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1110 zhao                    1606635 11-2月 -18 03.20.04.000000 下午                                                  DELETE              11-2月 -18 03.01.24.000000 下午                                                  11-2月 -18 03.20.10.000000 下午3333 yanyan                  1606931 11-2月 -18 03.24.32.000000 下午                                                  INSERT              11-2月 -18 03.24.32.000000 下午                                                  11-2月 -18 03.24.38.000000 下午4444 a                      1607467 11-2月 -18 03.35.50.000000 下午                                                  DELETE              11-2月 -18 03.35.13.000000 下午                                                  11-2月 -18 03.36.02.000000 下午1112 test                    1606066 11-2月 -18 03.05.59.000000 下午                                                  INSERT              11-2月 -18 03.05.59.000000 下午                                                  11-2月 -18 03.06.11.000000 下午1222 zhaozhao                1606635 11-2月 -18 03.20.04.000000 下午                                                  INSERT              11-2月 -18 03.20.04.000000 下午                                                  11-2月 -18 03.20.10.000000 下午4444 a                      1607464 11-2月 -18 03.35.46.000000 下午                                                  INSERT              11-2月 -18 03.35.46.000000 下午                                                  11-2月 -18 03.36.02.000000 下午9 rows selectedSQL> select * from nopk_tab_HIS;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao                400.00    103333 yanyan                  500.00    201111 yan                    100.00    101111 dong                    100.00    304444 a                      300.00    101112 test                    300.00    204444 a                      300.00    107 rows selectedSQL> select * from nopk_tab_DEL;EMPNO ENAME                      SAL DEPTNO BEFORE_AFTER        DEL_DATE                                                                        OP_FLAG
------- -------------------- --------- ------ -------------------- -------------------------------------------------------------------------------- --------------------4444 a                      300.00    10 BEFORE              11-2月 -18 03.35.50.016297 下午                                                  DELETE1111 dong                    100.00    30 BEFORE              11-2月 -18 03.05.59.015810 下午                                                  DELETE4444 a                      300.00    10 BEFORE              11-2月 -18 03.35.43.016297 下午                                                  DELETE

也是正常的,通过上面验证,证明DEL可以累积同一主键号的删除历史纪录,证明参数NOCOMPRESSDELETES 的确如文档所说能够完整的捕获到被删除记录的完整记录并写到trail文件中|,
和参数NSERTDELETES一起使用的确可以实现历史表中只存放被删除的记录。

接下来再测试一下修改表结构,在进行增删改,del表能否正常捕获:
1.实验开始前的表结构,以及表信息(还是跟着上面过程来的,期间自己又做过别的测试,数据与上面上次做完的实验会有所不同,但是表结构还是已经改为一致了):

-----------源端表结构以及数据:
SQL> desc dept;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
DEPTNO NUMBER(2)                              
DNAME  VARCHAR2(14) Y                         
LOC    VARCHAR2(13) Y                         
SQL> select * from dept;
DEPTNO DNAME          LOC
------ -------------- -------------1 a              b23 bbbbb          b3 cccc           b4 a              b5 a              b6 a              b12 ada            b13 a              b15 a              b16 a              b
10 rows selected
SQL> desc nopk_tab;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
EMPNO  NUMBER(6)    Y                         
ENAME  VARCHAR2(20) Y                         
SAL    NUMBER(7,2)  Y                         
DEPTNO NUMBER(4)    Y                         
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao               1000.00     103333 yanyan                  500.00     201111 yan                     100.00     10-------------目的端表结构和表数据:
SQL> desc dept;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
DEPTNO NUMBER(2)                              
DNAME  VARCHAR2(14) Y                         
LOC    VARCHAR2(13) Y                         
SQL> desc dept_his;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
DEPTNO NUMBER(2)    Y                         
DNAME  VARCHAR2(14) Y                         
LOC    VARCHAR2(13) Y                         
SQL> desc dept_audit;
Name       Type         Nullable Default Comments 
---------- ------------ -------- ------- -------- 
DEPTNO     NUMBER(2)    Y                         
CSN        NUMBER       Y                         
OPTIME     TIMESTAMP(6) Y                         
OPTYPE     VARCHAR2(20) Y                         
INSERTTIME TIMESTAMP(6) Y                         
CURDATE    TIMESTAMP(6) Y                         
SQL> desc dept_del;
Name         Type         Nullable Default Comments 
------------ ------------ -------- ------- -------- 
DEPTNO       NUMBER(2)    Y                         
DNAME        VARCHAR2(14) Y                         
LOC          VARCHAR2(13) Y                         
BEFORE_AFTER VARCHAR2(20) Y                         
DEL_DATE     TIMESTAMP(6) Y                         
OP_FLAG      VARCHAR2(20) Y              SQL> select * from dept;
DEPTNO DNAME          LOC
------ -------------- -------------1 A              B23 bbbbb          B3 cccc           B4 A              B5 A              B6 A              B12 ada            b13 a              b15 a              b16 a              b
10 rows selected
SQL> select * from dept_HIS;
DEPTNO DNAME          LOC
------ -------------- -------------1 A              B23 bbbbb          B3 cccc           B4 A              B5 A              B6 A              B7 A              B8 a              b9 aaa            b10 a              b12 ada            b13 a              b14 a              b15 a              b16 a              b14 a              b14 a              b14 a              b14 a              b41 a              a
DEPTNO DNAME          LOC
------ -------------- -------------11 a              b33 a              a33 a              a
23 rows selected

在这里插入图片描述
在这里插入图片描述

SQL> desc nopk_tab;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
EMPNO  NUMBER(6)    Y                         
ENAME  VARCHAR2(20) Y                         
SAL    NUMBER(7,2)  Y                         
DEPTNO NUMBER(4)    Y                         
SQL> desc nopk_tab_audit;
Name       Type         Nullable Default Comments 
---------- ------------ -------- ------- -------- 
EMPNO      NUMBER(6)    Y                         
ENAME      VARCHAR2(20) Y                         
CSN        NUMBER       Y                         
OPTIME     TIMESTAMP(6) Y                         
OPTYPE     VARCHAR2(20) Y                         
INSERTTIME TIMESTAMP(6) Y                         
CURDATE    TIMESTAMP(6) Y                         
SQL> desc nopk_tab_del;
Name         Type         Nullable Default Comments 
------------ ------------ -------- ------- -------- 
EMPNO        NUMBER(6)    Y                         
ENAME        VARCHAR2(20) Y                         
SAL          NUMBER(7,2)  Y                         
DEPTNO       NUMBER(4)    Y                         
BEFORE_AFTER VARCHAR2(20) Y                         
DEL_DATE     TIMESTAMP(6) Y                         
OP_FLAG      VARCHAR2(20) Y                         
SQL> desc nopk_tab_his;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
EMPNO  NUMBER(6)    Y                         
ENAME  VARCHAR2(20) Y                         
SAL    NUMBER(7,2)  Y                         
DEPTNO NUMBER(4)    Y          SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------3333 yanyan                  500.00     201111 yan                     100.00     101222 zhaozhao               1000.00     10
SQL> select * from nopk_tab_HIS;EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------1222 zhaozhao               1000.00     103333 yanyan                  500.00     201111 yan                     100.00     101111 dong                    100.00     301001 aa                       22.00      14444 a                       300.00     101112 test                    300.00     204444 a                       300.00     10
8 rows selected

在这里插入图片描述
在这里插入图片描述
源端和目的端表结构和数据均已经知道。现在在源端分别给dept表和nopk_tab 表增加一列 test number;

alter table dept add test number;
alter table nopk_tab add test number;

然后切换一下归档日志:

alter system switch logfile;
alter system switch logfile;

然后去目的端分别查看这两张表的源表和其他映射表的表结构:

SQL> desc dept;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
DEPTNO NUMBER(2)                              
DNAME  VARCHAR2(14) Y                         
LOC    VARCHAR2(13) Y                         
TEST   NUMBER       Y                         
SQL> desc dept_his;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
DEPTNO NUMBER(2)    Y                         
DNAME  VARCHAR2(14) Y                         
LOC    VARCHAR2(13) Y                         
TEST   NUMBER       Y                         
SQL> desc dept_audit;
Name       Type         Nullable Default Comments 
---------- ------------ -------- ------- -------- 
DEPTNO     NUMBER(2)    Y                         
CSN        NUMBER       Y                         
OPTIME     TIMESTAMP(6) Y                         
OPTYPE     VARCHAR2(20) Y                         
INSERTTIME TIMESTAMP(6) Y                         
CURDATE    TIMESTAMP(6) Y                         
SQL> desc dept_del;
Name         Type         Nullable Default Comments 
------------ ------------ -------- ------- -------- 
DEPTNO       NUMBER(2)    Y                         
DNAME        VARCHAR2(14) Y                         
LOC          VARCHAR2(13) Y                         
BEFORE_AFTER VARCHAR2(20) Y                         
DEL_DATE     TIMESTAMP(6) Y                         
OP_FLAG      VARCHAR2(20) Y                         
TEST         NUMBER       Y    SQL> desc nopk_tab;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
EMPNO  NUMBER(6)    Y                         
ENAME  VARCHAR2(20) Y                         
SAL    NUMBER(7,2)  Y                         
DEPTNO NUMBER(4)    Y                         
TEST   NUMBER       Y                         
SQL> desc nopk_tab_audit;
Name       Type         Nullable Default Comments 
---------- ------------ -------- ------- -------- 
EMPNO      NUMBER(6)    Y                         
ENAME      VARCHAR2(20) Y                         
CSN        NUMBER       Y                         
OPTIME     TIMESTAMP(6) Y                         
OPTYPE     VARCHAR2(20) Y                         
INSERTTIME TIMESTAMP(6) Y                         
CURDATE    TIMESTAMP(6) Y                         
SQL> desc nopk_tab_del;
Name         Type         Nullable Default Comments 
------------ ------------ -------- ------- -------- 
EMPNO        NUMBER(6)    Y                         
ENAME        VARCHAR2(20) Y                         
SAL          NUMBER(7,2)  Y                         
DEPTNO       NUMBER(4)    Y                         
BEFORE_AFTER VARCHAR2(20) Y                         
DEL_DATE     TIMESTAMP(6) Y                         
OP_FLAG      VARCHAR2(20) Y                         
TEST         NUMBER       Y                         
SQL> desc nopk_tab_his;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
EMPNO  NUMBER(6)    Y                         
ENAME  VARCHAR2(20) Y                         
SAL    NUMBER(7,2)  Y                         
DEPTNO NUMBER(4)    Y                         
TEST   NUMBER       Y                         

从上面ddl操作结果来看,源端的ddl操作的确应用过来了。而且在report中也有记录:

GGSCI (OGG) 4> view report r_sc2
最后面内容如下:
2018-02-24 17:21:22  INFO    OGG-00482  DDL found, operation [alter table dept add test number(size 34)].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT add test number(size 40)].2018-02-24 17:21:22  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT].2018-02-24 17:21:22  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-24 17:21:22  INFO    OGG-00484  Executing DDL operation.2018-02-24 17:21:22  INFO    OGG-00483  DDL operation successful.2018-02-24 17:21:22  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT_HIS add test number(size 44)].2018-02-24 17:21:22  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT_HIS].2018-02-24 17:21:22  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-24 17:21:22  INFO    OGG-00484  Executing DDL operation.2018-02-24 17:21:22  INFO    OGG-00483  DDL operation successful.2018-02-24 17:21:22  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT_AUDIT add test number(size 46)].2018-02-24 17:21:22  INFO    OGG-00488  DDL operation excluded [exclude objname scott.*_audit], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT_AUDIT].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT_DEL add test number(size 44)].2018-02-24 17:21:22  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT_DEL].2018-02-24 17:21:22  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-24 17:21:22  INFO    OGG-00484  Executing DDL operation.2018-02-24 17:21:22  INFO    OGG-00483  DDL operation successful.2018-02-24 17:21:22  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-24 17:21:22  INFO    OGG-00482  DDL found, operation [alter table nopk_tab add test number(size 38)].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB add test number(size 44)].2018-02-24 17:21:22  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB].2018-02-24 17:21:22  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-24 17:21:22  INFO    OGG-00484  Executing DDL operation.2018-02-24 17:21:22  INFO    OGG-00483  DDL operation successful.2018-02-24 17:21:22  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB_HIS add test number(size 48)].2018-02-24 17:21:22  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB_HIS].2018-02-24 17:21:22  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-24 17:21:22  INFO    OGG-00484  Executing DDL operation.2018-02-24 17:21:22  INFO    OGG-00483  DDL operation successful.2018-02-24 17:21:22  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB_AUDIT add test number(size 50)].2018-02-24 17:21:22  INFO    OGG-00488  DDL operation excluded [exclude objname scott.*_audit], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB_AUDIT].2018-02-24 17:21:22  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB_DEL add test number(size 48)].2018-02-24 17:21:22  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB_DEL].2018-02-24 17:21:22  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-24 17:21:22  INFO    OGG-00484  Executing DDL operation.2018-02-24 17:21:22  INFO    OGG-00483  DDL operation successful.2018-02-24 17:21:22  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].

但是我们也能发现,新增加的一列会放到表列的最后面,在XXXXDEL表中显示的不友好,笔者这边需求是这个DEL表的表结构要与源表一致,本人DEL表多出来的那几列是
本人为了测试方便,以及为后面update和PKUPDATE 前映像测试显示方便而加的,所以并不影响原来需求。
现在分别在源端对这两个表进行增删改操作:

insert into dept values(43,'a','a',1);
insert into nopk_tab values(1003,'aa',22,1,12);
SQL> select * from dept;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------1 a              b             23 bbbbb          b             3 cccc           b             4 a              b             5 a              b             6 a              b             43 a              a                      112 ada            b             13 a              b             15 a              b             16 a              b             
11 rows selectedSQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------1003 aa                       22.00      1         121222 zhaozhao               1000.00     10 3333 yanyan                  500.00     20 1111 yan                     100.00     10 update dept set test=111 where deptno=1;
update nopk_tab set test=122 where empno=1222;EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------1003 aa                       22.00      1         121222 zhaozhao               1000.00     10        1223333 yanyan                  500.00     20 1111 yan                     100.00     10 
SQL> select * from dept;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------1 a              b                    11123 bbbbb          b             3 cccc           b             4 a              b             5 a              b             6 a              b             43 a              a                      112 ada            b             13 a              b             15 a              b             16 a              b             
11 rows selecteddelete from dept where deptno=43;
delete from nopk_tab where empno=1003;SQL> select * from dept;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------1 a              b                    11123 bbbbb          b             3 cccc           b             4 a              b             5 a              b             6 a              b             12 ada            b             13 a              b             15 a              b             16 a              b             
10 rows selected
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------1222 zhaozhao               1000.00     10        1223333 yanyan                  500.00     20 1111 yan                     100.00     10 好了,现在去目的端查看表内容:
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;SQL> select * from dept;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------1 A              B                    11123 bbbbb          B             3 cccc           B             4 A              B             5 A              B             6 A              B             12 ada            b             13 a              b             15 a              b             16 a              b             
10 rows selected
SQL> select * from dept_his;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------1 A              B                    11123 bbbbb          B             3 cccc           B             4 A              B             5 A              B             6 A              B             7 A              B             8 a              b             9 aaa            b             10 a              b             12 ada            b             13 a              b             14 a              b             15 a              b             16 a              b             14 a              b             14 a              b             14 a              b             14 a              b             41 a              a             
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------43 a              a                      111 a              b             33 a              a             33 a              a             
24 rows selected

在这里插入图片描述
在这里插入图片描述

SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------3333 yanyan                  500.00     20 1111 yan                     100.00     10 1222 zhaozhao               1000.00     10        122
SQL> select * from nopk_tab_his;EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------1222 zhaozhao               1000.00     10        1223333 yanyan                  500.00     20 1111 yan                     100.00     10 1111 dong                    100.00     30 1001 aa                       22.00      1 1003 aa                       22.00      1         124444 a                       300.00     10 1112 test                    300.00     20 4444 a                       300.00     10 

在这里插入图片描述
发现仍然可以成功捕获,这是应当的。在测试一下多次插入删除同一条sql:
-----源端操作:

insert into dept values(43,'a','a',1);
insert into nopk_tab values(1003,'aa',22,1,12);
delete from dept where deptno=41;
delete from nopk_tab where empno=1001;
alter system switch logfile;

—目的端查看:
在这里插入图片描述

SQL> select * from dept_his;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------1 A              B                    11123 bbbbb          B             3 cccc           B             4 A              B             5 A              B             6 A              B             7 A              B             8 a              b             9 aaa            b             10 a              b             12 ada            b             13 a              b             14 a              b             15 a              b             16 a              b             14 a              b             14 a              b             14 a              b             14 a              b             41 a              a             
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------43 a              a                      143 a              a                      111 a              b             33 a              a             33 a              a             
25 rows selected
SQL> select * from nopk_tab_his;EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------1222 zhaozhao               1000.00     10        1223333 yanyan                  500.00     20 1111 yan                     100.00     10 1111 dong                    100.00     30 1001 aa                       22.00      1 1003 aa                       22.00      1         121003 aa                       22.00      1         124444 a                       300.00     10 1112 test                    300.00     20 4444 a                       300.00     10 
10 rows selected

在这里插入图片描述
在这里插入图片描述

SQL> select * from dept;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------1 A              B                    11123 bbbbb          B             3 cccc           B             4 A              B             5 A              B             6 A              B             12 ada            b             13 a              b             15 a              b             16 a              b             
10 rows selected
SQL> select * from nopk_tab;EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------3333 yanyan                  500.00     20 1111 yan                     100.00     10 1222 zhaozhao               1000.00     10        122

发现结果仍然是正常的。本来就应该是正常的,但是为了保险起见,才做了一下多余的测试,毕竟应用到生产,全公司的ODS平台都应用此配置,好了现在再再源端那两张表中
删除新加的test列:

alter table dept drop column test;
alter table nopk_tab drop column test;
alter system switch logfile;

接下来在目的端查看:
先看report文件:

view report r_sc2
2018-02-26 09:19:29  INFO    OGG-00482  DDL found, operation [alter table dept drop column test  (size 34)].2018-02-26 09:19:29  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT drop column test  (size 40)].2018-02-26 09:19:29  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT].2018-02-26 09:19:29  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-26 09:19:29  INFO    OGG-00484  Executing DDL operation.2018-02-26 09:19:30  INFO    OGG-00483  DDL operation successful.2018-02-26 09:19:30  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-26 09:19:30  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT_HIS drop column test  (size 44)].2018-02-26 09:19:30  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT_HIS].2018-02-26 09:19:30  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-26 09:19:30  INFO    OGG-00484  Executing DDL operation.2018-02-26 09:19:30  INFO    OGG-00483  DDL operation successful.2018-02-26 09:19:30  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-26 09:19:30  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT_AUDIT drop column test  (size 46)].2018-02-26 09:19:30  INFO    OGG-00488  DDL operation excluded [exclude objname scott.*_audit], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT_AUDIT].2018-02-26 09:19:30  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.DEPT_DEL drop column test  (size 44)].2018-02-26 09:19:30  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [DEPT_DEL].2018-02-26 09:19:30  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-26 09:19:30  INFO    OGG-00484  Executing DDL operation.2018-02-26 09:19:30  INFO    OGG-00483  DDL operation successful.2018-02-26 09:19:30  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-26 09:19:30  INFO    OGG-00482  DDL found, operation [alter table nopk_tab drop column test  (size 38)].2018-02-26 09:19:30  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB drop column test  (size 44)].2018-02-26 09:19:30  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB].2018-02-26 09:19:30  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-26 09:19:30  INFO    OGG-00484  Executing DDL operation.2018-02-26 09:19:30  INFO    OGG-00483  DDL operation successful.2018-02-26 09:19:30  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-26 09:19:30  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB_HIS drop column test  (size 48)].2018-02-26 09:19:30  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB_HIS].2018-02-26 09:19:30  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-26 09:19:30  INFO    OGG-00484  Executing DDL operation.2018-02-26 09:19:30  INFO    OGG-00483  DDL operation successful.2018-02-26 09:19:30  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].2018-02-26 09:19:30  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB_AUDIT drop column test  (size 50)].2018-02-26 09:19:30  INFO    OGG-00488  DDL operation excluded [exclude objname scott.*_audit], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB_AUDIT].2018-02-26 09:19:30  INFO    OGG-00489  DDL is of mapped scope, after mapping new operation [alter table SCOTT.NOPK_TAB_DEL drop column test  (size 48)].2018-02-26 09:19:30  INFO    OGG-00487  DDL operation included [include mapped], optype [ALTER], objtype [TABLE], objowner [SCOTT], objname [NOPK_TAB_DEL].2018-02-26 09:19:30  INFO    OGG-01407  Setting current schema for DDL operation to [SCOTT].2018-02-26 09:19:30  INFO    OGG-00484  Executing DDL operation.2018-02-26 09:19:30  INFO    OGG-00483  DDL operation successful.2018-02-26 09:19:30  INFO    OGG-01408  Restoring current schema for DDL operation to [ogg].
提示成功捕获到了ddl,看一下表结构:
SQL> desc dept;
Name                      Null?    Type
----------------------------------------- -------- ----------------------------
DEPTNO                    NOT NULL NUMBER(2)
DNAME                            VARCHAR2(14)
LOC                            VARCHAR2(13)SQL> desc dept_his;
Name                      Null?    Type
----------------------------------------- -------- ----------------------------
DEPTNO                        NUMBER(2)
DNAME                            VARCHAR2(14)
LOC                            VARCHAR2(13)SQL> desc dept_del;
Name                      Null?    Type
----------------------------------------- -------- ----------------------------
DEPTNO                        NUMBER(2)
DNAME                            VARCHAR2(14)
LOC                            VARCHAR2(13)
BEFORE_AFTER                        VARCHAR2(20)
DEL_DATE                        TIMESTAMP(6)
OP_FLAG                        VARCHAR2(20)
接下来再看一下nopk_tab的:
SQL> desc nopk_tab;
Name                      Null?    Type
----------------------------------------- -------- ----------------------------
EMPNO                            NUMBER(6)
ENAME                            VARCHAR2(20)
SAL                            NUMBER(7,2)
DEPTNO                        NUMBER(4)SQL> desc nopk_tab_his;
Name                      Null?    Type
----------------------------------------- -------- ----------------------------
EMPNO                            NUMBER(6)
ENAME                            VARCHAR2(20)
SAL                            NUMBER(7,2)
DEPTNO                        NUMBER(4)SQL> desc nopk_tab_del;
Name                      Null?    Type
----------------------------------------- -------- ----------------------------
EMPNO                            NUMBER(6)
ENAME                            VARCHAR2(20)
SAL                            NUMBER(7,2)
DEPTNO                        NUMBER(4)
BEFORE_AFTER                        VARCHAR2(20)
DEL_DATE                        TIMESTAMP(6)
OP_FLAG                        VARCHAR2(20)

十一、在另一个文章:【大数据实时数据同步】OGG多路映射同步原表&审计表&只存删除数据表实现方案(二)

相关内容

热门资讯

常用商务英语口语   商务英语是以适应职场生活的语言要求为目的,内容涉及到商务活动的方方面面。下面是小编收集的常用商务...
六年级上册英语第一单元练习题   一、根据要求写单词。  1.dry(反义词)__________________  2.writ...
复活节英文怎么说 复活节英文怎么说?复活节的英语翻译是什么?复活节:Easter;"Easter,anniversar...
2008年北京奥运会主题曲 2008年北京奥运会(第29届夏季奥林匹克运动会),2008年8月8日到2008年8月24日在中华人...
英语道歉信 英语道歉信15篇  在日常生活中,道歉信的使用频率越来越高,通过道歉信,我们可以更好地解释事情发生的...
六年级英语专题训练(连词成句... 六年级英语专题训练(连词成句30题)  1. have,playhouse,many,I,toy,i...
上班迟到情况说明英语   每个人都或多或少的迟到过那么几次,因为各种原因,可能生病,可能因为交通堵车,可能是因为天气冷,有...
小学英语教学论文 小学英语教学论文范文  引导语:英语教育一直都是每个家长所器重的,那么有关小学英语教学论文要怎么写呢...
英语口语学习必看的方法技巧 英语口语学习必看的方法技巧如何才能说流利的英语? 说外语时,我们主要应做到四件事:理解、回答、提问、...
四级英语作文选:Birth ... 四级英语作文范文选:Birth controlSince the Chinese Governmen...
金融专业英语面试自我介绍 金融专业英语面试自我介绍3篇  金融专业的学生面试时,面试官要求用英语做自我介绍该怎么说。下面是小编...
我的李老师走了四年级英语日记... 我的李老师走了四年级英语日记带翻译  我上了五个学期的小学却换了六任老师,李老师是带我们班最长的语文...
小学三年级英语日记带翻译捡玉... 小学三年级英语日记带翻译捡玉米  今天,我和妈妈去外婆家,外婆家有刚剥的`玉米棒上带有玉米籽,好大的...
七年级英语优秀教学设计 七年级英语优秀教学设计  作为一位兢兢业业的人民教师,常常要写一份优秀的教学设计,教学设计是把教学原...
我的英语老师作文 我的英语老师作文(通用21篇)  在日常生活或是工作学习中,大家都有写作文的经历,对作文很是熟悉吧,...
英语老师教学经验总结 英语老师教学经验总结(通用19篇)  总结是指社会团体、企业单位和个人对某一阶段的学习、工作或其完成...
初一英语暑假作业答案 初一英语暑假作业答案  英语练习一(基础训练)第一题1.D2.H3.E4.F5.I6.A7.J8.C...
大学生的英语演讲稿 大学生的英语演讲稿范文(精选10篇)  使用正确的写作思路书写演讲稿会更加事半功倍。在现实社会中,越...
VOA美国之音英语学习网址 VOA美国之音英语学习推荐网址 美国之音网站已经成为语言学习最重要的资源站点,在互联网上还有若干网站...
商务英语期末试卷 Part I Term Translation (20%)Section A: Translate ...