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

news2024/11/15 4:35:27

置顶!!!主页禁言提示原因:在自己论坛发动态误带敏感词,在自己论坛禁止评论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 -v

Oracle 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:21

Copyright (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 USERS
  PCTFREE 10
  INITRANS 1
  MAXTRANS 255
  STORAGE
  (
    INITIAL 64K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
  );
-- CREATE/RECREATE PRIMARY, UNIQUE AND FOREIGN KEY CONSTRAINTS 
ALTER TABLE DEPT
  ADD CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO)
  USING INDEX 
  TABLESPACE USERS
  PCTFREE 10
  INITRANS 2
  MAXTRANS 255
  STORAGE
  (
    INITIAL 64K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS 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              b
    2 a              b
    3 a              b
    4 a              b
    5 a              b
    6 a              b
    7 a              b
    8 a              b
    9 a              b
    10 a              b

10 rows selected

SQL> insert into dept values(11,'a','b');

1 row inserted

SQL>delete from dept where deptno=10;

1 row deleted

SQL> update dept set dname='aaa'where deptno=9;

1 row updated

SQL> commit;

Commit complete

SQL> alter system switch logfile;

System altered

SQL> /

System altered

SQL> select * from dept;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 a              b
    2 a              b
    3 a              b
    4 a              b
    5 a              b
    6 a              b
    7 a              b
    8 a              b
    9 aaa            b
    11 a              b

10 rows selected

-----------------------------在目的端查看:
SQL> select * from dept;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    2 A              B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    11 a              b

10 rows selected

SQL> 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 selected

SQL> select * from dept_his;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    2 A              B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    10 a              b
    11 a              b

11 rows selected

SQL> 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    10
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1111 dong                    100.00    30

SQL> insert into nopk_tab values(1112,'test',300,20);

1 row inserted


SQL> delete from nopk_tab where empno=1111 and ename='dong';

1 row deleted


SQL> update nopk_tab set sal=400 where empno=1110 and ename='zhao';

1 row updated


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered

SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1110 zhao                    400.00    10
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1112 test                    300.00    20

----------------------------------------------------在目标端查看

SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1110 zhao                    400.00    10
  1112 test                    300.00    20

SQL> 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    10
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1111 dong                    100.00    30
  1112 test                    300.00    20

SQL> 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              b
    2 a              b
    3 a              b
    4 a              b
    5 a              b
    6 a              b
    7 a              b
    8 a              b
    9 aaa            b
    11 a              b

10 rows selected

SQL> update dept set deptno=22, dname='b' where deptno=2;

1 row updated


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered


SQL> alter system switch logfile;

System altered
在目的端查看:
SQL> select * from dept;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    22 b              B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    11 a              b

10 rows selected

SQL> 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 selected

SQL> select * from dept_his;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    22 b              B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    10 a              b
    11 a              b

11 rows selected

SQL> 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    10
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1112 test                    300.00    20

SQL> update nopk_tab set empno=1222,ename='zhaozhao' where empno=1110 and ename='zhao';

1 row updated


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered
SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1222 zhaozhao                400.00    10
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1112 test                    300.00    20

-----------查看目的端
SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1222 zhaozhao                400.00    10
  1112 test                    300.00    20

SQL> 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 selected


SQL> select * from nopk_tab_HIS;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1222 zhaozhao                400.00    10
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1111 dong                    100.00    30
  1112 test                    300.00    20

SQL> 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    10
  1110 yan                    200.00    20
  1111 yan                    100.00    10
  1112 test                    300.00    20

SQL> update nopk_tab set empno=3333,ename='yanyan',sal=500 where empno=1110 and ename='yan';

1 row updated


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered


SQL> alter system switch logfile;

System altered


SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1222 zhaozhao                400.00    10
  3333 yanyan                  500.00    20
  1111 yan                    100.00    10
  1112 test                    300.00    20
目的端查看

SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  3333 yanyan                  500.00    20
  1111 yan                    100.00    10
  1222 zhaozhao                400.00    10
  1112 test                    300.00    20

SQL> 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 selected


SQL> select * from nopk_tab_HIS;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1222 zhaozhao                400.00    10
  3333 yanyan                  500.00    20
  1111 yan                    100.00    10
  1111 dong                    100.00    30
  1112 test                    300.00    20

SQL> 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 inserted

SQL> select * from dept;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 a              b
    23 bbbbb          b
    3 a              b
    4 a              b
    5 a              b
    6 a              b
    7 a              b
    8 a              b
    9 aaa            b
    11 a              b
    33 a              a

11 rows selected


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered
目的端查看:
SQL> select * from dept;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    23 bbbbb          B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    11 a              b
    33 a              a

11 rows selected
同步过来了,源端再执行删除:

SQL> delete from dept where deptno=33;

1 row deleted


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered
再来目的端查看:
SQL> select * from dept;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    23 bbbbb          B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    11 a              b

10 rows selected


SQL> 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 selected


SQL> select * from dept_his;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    23 bbbbb          B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    10 a              b
    11 a              b
    33 a              a

12 rows selected


SQL> 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
    33 a              a            BEFORE              11-2-18 03.29.38.015754 下午                                                  DELETE
再在源端进行插入同一记录,在删除:
SQL> insert into dept values(33,'a','a');

1 row inserted


SQL> commit;

Commit complete


SQL> delete from dept where deptno=33;

1 row deleted


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered


在目睹端查看:
SQL> select * from dept;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    23 bbbbb          B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    11 a              b

10 rows selected


SQL> 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 selected


SQL> select * from dept_his;

DEPTNO DNAME          LOC
------ -------------- -------------
    1 A              B
    23 bbbbb          B
    3 A              B
    4 A              B
    5 A              B
    6 A              B
    7 A              B
    8 A              B
    9 aaa            B
    10 a              b
    11 a              b
    33 a              a
    33 a              a

13 rows selected


SQL> 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
    33 a              a            BEFORE              11-2-18 03.29.38.015754 下午                                                  DELETE
    33 a              a            BEFORE              11-2-18 03.31.06.015751 下午                                                  DELETE

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

-----源端进行如下操作:
SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1222 zhaozhao                400.00    10
  3333 yanyan                  500.00    20
  1111 yan                    100.00    10
  1112 test                    300.00    20

SQL> insert into nopk_tab values(4444,'a',300,10);

1 row inserted


SQL> commit;

Commit complete


SQL> delete from nopk_tab where empno=4444;

1 row deleted


SQL> commit;

Commit complete


SQL> insert into nopk_tab values(4444,'a',300,10);

1 row inserted


SQL> commit;

Commit complete


SQL> delete from nopk_tab where empno=4444;

1 row deleted


SQL> commit;

Commit complete


SQL> alter system switch logfile;

System altered

----------目的端查看:
SQL> select * from nopk_tab;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  3333 yanyan                  500.00    20
  1111 yan                    100.00    10
  1222 zhaozhao                400.00    10
  1112 test                    300.00    20


SQL> 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 selected


SQL> select * from nopk_tab_HIS;

  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
  1222 zhaozhao                400.00    10
  3333 yanyan                  500.00    20
  1111 yan                    100.00    10
  1111 dong                    100.00    30
  4444 a                      300.00    10
  1112 test                    300.00    20
  4444 a                      300.00    10

7 rows selected


SQL> 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 下午                                                  DELETE
  1111 dong                    100.00    30 BEFORE              11-2-18 03.05.59.015810 下午                                                  DELETE
  4444 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              b
    23 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> 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     10
   3333 yanyan                  500.00     20
   1111 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              B
    23 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
------ -------------- -------------
     1 A              B
    23 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
------ -------------- -------------
    11 a              b
    33 a              a
    33 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     20
   1111 yan                     100.00     10
   1222 zhaozhao               1000.00     10
SQL> select * from nopk_tab_HIS;
  EMPNO ENAME                      SAL DEPTNO
------- -------------------- --------- ------
   1222 zhaozhao               1000.00     10
   3333 yanyan                  500.00     20
   1111 yan                     100.00     10
   1111 dong                    100.00     30
   1001 aa                       22.00      1
   4444 a                       300.00     10
   1112 test                    300.00     20
   4444 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                      1
    12 ada            b             
    13 a              b             
    15 a              b             
    16 a              b             
11 rows selected

SQL> select * from nopk_tab;
  EMPNO ENAME                      SAL DEPTNO       TEST
------- -------------------- --------- ------ ----------
   1003 aa                       22.00      1         12
   1222 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         12
   1222 zhaozhao               1000.00     10        122
   3333 yanyan                  500.00     20 
   1111 yan                     100.00     10 
SQL> select * from dept;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------
     1 a              b                    111
    23 bbbbb          b             
     3 cccc           b             
     4 a              b             
     5 a              b             
     6 a              b             
    43 a              a                      1
    12 ada            b             
    13 a              b             
    15 a              b             
    16 a              b             
11 rows selected

delete from dept where deptno=43;
delete from nopk_tab where empno=1003;

SQL> select * from dept;
DEPTNO DNAME          LOC                 TEST
------ -------------- ------------- ----------
     1 a              b                    111
    23 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        122
   3333 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                    111
    23 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                    111
    23 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                      1
    11 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        122
   3333 yanyan                  500.00     20 
   1111 yan                     100.00     10 
   1111 dong                    100.00     30 
   1001 aa                       22.00      1 
   1003 aa                       22.00      1         12
   4444 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                    111
    23 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                      1
    43 a              a                      1
    11 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        122
   3333 yanyan                  500.00     20 
   1111 yan                     100.00     10 
   1111 dong                    100.00     30 
   1001 aa                       22.00      1 
   1003 aa                       22.00      1         12
   1003 aa                       22.00      1         12
   4444 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                    111
    23 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多路映射同步原表&审计表&只存删除数据表实现方案(二)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/383062.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

RAD Studio 11.3 Alexandria Crack

RAD Studio 11.3 Alexandria Crack 瞄准最新平台版本-此版本增加了对Android 13和Apple macOS Ventura的官方支持。它还支持Ubuntu 22 LTS和Microsoft Windows Server 2022。 使用生物特征认证-New为FireMonkey移动应用程序提供了新的移动生物特征认证组件。 部署嵌入式InterBa…

【Python学习笔记】第二十五节 Python MySQL

Python 连接到 MySQL 数据库有几种不同的连接方法,而且不是所有的方法都能与不同的操作系统很好地配合.MySQL connector/Python模块是Oracle支持的官方驱动,用于通过Python连接MySQL。该连接器完全是Python语言,而mysqlclient是用C语言编写的…

Java的开发工具有哪些?这十款工具大厂都在用!

工欲善其事必先利其器,各位同学大家好,我是小源~本期文章,给大家推荐十款Java的开发工具。一、 文本编辑器主要推荐三款:notepad、editplus、sublime text。这三款编辑工具,在我们的开发工作中几乎是相差无几&#xff…

3. 字符设备驱动---上篇

文章目录引言一、字符设备驱动工作原理1.1 系统整体工作原理1.2 字符驱动模型1.2.1 file_operations结构体1.2.2 注册字符设备驱动 --- 申请主设备号1.2.3 内核如何管理字符设备驱动二、字符设备驱动代码实践2.1 编写字符设备驱动的步骤和规范2.2 实践写驱动代码2.3 代码实现2.…

Matplotlib精品学习笔记001——绘制3D图形详解+实例讲解

3D图片更生动,或许在时间序列数据的展示上更胜一筹 想法: 学习3D绘图的想法来自科研绘图中。我从事的专业是古植物学,也就是和植物化石打交道。化石有三大信息:1.物种信息,也就是它的分类学价值;2.时间信息…

RealBasicVSR模型转成ONNX以及用c++推理

文章目录安装RealBasicVSR的环境1. 新建一个conda环境2. 安装pytorch(官网上选择合适的版本)版本太低会有问题3. 安装 mim 和 mmcv-full4. 安装 mmedit下载RealBasicVSR源码下载模型文件写一个模型转换的脚步测试生成的模型安装RealBasicVSR的环境 1. 新建一个conda环境 cond…

第一次做性能测试,有亿点点紧张

确认需求 确定性能需求和性能测试方案、需要确定性能测试范围(覆盖哪些场景)、性能测试策略、并发用户数和加压方式。 时间、人员、任务的分配安排,一般在总体测试计划中会预留性能测试的时间。性能测试方案是开展性能测试前的核心内容&…

时序预测 | MATLAB实现Rmsprop算法优化LSTM长短期记忆神经网络时间序列多步预测(滚动预测未来,多指标,含验证Loss曲线)

时序预测 | MATLAB实现Rmsprop算法优化LSTM长短期记忆神经网络时间序列多步预测(滚动预测未来,多指标,含训练和验证Loss曲线) 目录 时序预测 | MATLAB实现Rmsprop算法优化LSTM长短期记忆神经网络时间序列多步预测(滚动预测未来,多指标,含训练和验证Loss曲线)效果一览基本描…

Flume使用入门

目录 一. Flume简单介绍 1. Agent 2. Source 3. Sink 4. Channel 5. Event 二. 环境安装 1. 创建日志目录 2. 修改日志配置文件 3.修改运行堆内存 4. 确定日志打印的位置 5. 修改flume使用内存 内存调大 三. 校验flume 1. 安装netcat工具和net-tools工具 2. 判…

MySQL服务端与客户端之间的连接过程

服务器程序和客户端程序本质上是两个进程,所以连接过程的本质就是两个进程直接的通信,MySQL支持下面三种方式来进行通信。一:TCP/IP数据库服务器进程和客户端进程可能运行在不同的主机中,需要通过网络来进行通信二:命名…

初识scrapy

认识scrapyscrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架,我们只需实现少量的代码,就能实现数据的快速抓取scrapy使用了Twisted异步网络架构,可以加快下载速度 pip install twisted安装:pip install s…

进程控制(详解)

进程控制上篇文章介绍了进程的相关概念,形如进程的内核数据结构task_struct 、进程是如何被操作系统管理的、进程的查看、进程标识符、进程状态、进程优先级、已经环境变量和进程地址空间等知识点; 本篇文章接着上篇文章继续对进程的控制进行展开&#x…

Spark 内存运用

RDD Cache 当同一个 RDD 被引用多次时,就可以考虑进行 Cache,从而提升作业的执行效率 // 用 cache 对 wordCounts 加缓存 wordCounts.cache // cache 后要用 action 才能触发 RDD 内存物化 wordCounts.count// 自定义 Cache 的存储介质、存储形式、副本…

【OJ比赛日历】快周末了,不来一场比赛吗? #03.04-03.10 #12场

CompHub 实时聚合多平台的数据类(Kaggle、天池…)和OJ类(Leetcode、牛客…)比赛。本账号同时会推送最新的比赛消息,欢迎关注!更多比赛信息见 CompHub主页 或 点击文末阅读原文以下信息仅供参考,以比赛官网为准目录2023-03-04&…

从100%进口到自主可控,从600块降到10块,中科院攻克重要芯片

前言 2月28日,“20多位中科院专家把芯片价格打到10块”冲上微博热搜,据河南省官媒大象新闻报道,热搜中提到的中科院专家所在企业为全球最大的PLC分路器芯片制造商仕佳光子,坐落于河南鹤壁。 为实现芯片技术自主可控自立自强&#…

根据栅格数据的范围和像元大小生成等比例的矢量数据

为啥会有这么一个需求呢,后面要是继续写的话会详细说,首先是有一个栅格数据,比如这样的:我的目标是这样的(矢量),就是这样,上面的栅格数据像大小是2*2的,直接上代码&…

【JAVA程序设计】【C00109】基于SSM(非maven)的员工工资管理系统

基于SSM(非maven)的员工工资管理系统项目简介项目获取开发环境项目技术运行截图项目简介 基于ssm框架非maven开发的企业工资管理系统共分为二个角色:系统管理员、员工 管理员角色包含以下功能: 系统后台登陆、管理员管理、员工信…

Linux基础命令-nice调整进程的优先级

文章目录 Nice 命令介绍 语法格式 常用参数 参考实例 1 调整bash的优先级为-10 2 调整脚本的优先级为6 3 调整指令的优先级 4 默认使用nice命令调整优先级 命令总结 Nice 命令介绍 nice命令的主要功能是用于调整进程的优先级,合理分配系统资源。Linux系…

torchaudio的I/O函数

info、load、save1.1 infotorchaudio.info(filepath: str, ...)Fetch meta data of an audio file. Refer to torchaudio.backend for the detail.返回音频文件的meta信息这里的meta元信息包括采样率、帧数、通道数、量化位数、音频格式info torchaudio.info(rE:\adins\data\2…

Java使用DFA算法实现敏感词过滤

1 前言敏感词过滤就是你在项目中输入某些字(比如输入xxoo相关的文字时)时要能检测出来,很多项目中都会有一个敏感词管理模块,在敏感词管理模块中你可以加入敏感词,然后根据加入的敏感词去过滤输入内容中的敏感词并进行…