INSERTDELETES&NOINSERTDELETES--GoldenGate Parameter

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 parametersare table-specific. One parameter remains in effect for all subsequent MAP

statements,until the other parameter is encountered.

When using INSERTDELETES, usethe NOCOMPRESSDELETES parameter so that Extract does not

compressdeletes.

Default NOINSERTDELETES

Syntax INSERTDELETES | NOINSERTDELETES

也就是说:此参数可以使得目标表中插入源表中被删除的记录,多用于业务跟踪或审计。请参考以下测试:

-==source==-
SQL> desc t1
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER

SQL> 

extract ext1
extract pum1
-==target==-

SQL> desc user2.t1hist
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 TS                                                 DATE
 BEFORE_AFTER                                       VARCHAR2(200)
 OP_TYPE                                            VARCHAR2(20)
 ID                                                 NUMBER

SQL>
SQL> truncate table user2.t1hist;

Table truncated.

SQL> 

replicat rep1
:::
MAP user1.*, TARGET user1.*;
INSERTDELETES
MAP user1.t1, TARGET user2.t1hist,
COLMAP (TS = @GETENV ("GGHEADER", "COMMITTIMESTAMP"),
BEFORE_AFTER = @GETENV ("GGHEADER", "BEFOREAFTERINDICATOR"),
OP_TYPE = @GETENV ("GGHEADER", "OPTYPE"),
ID = ID);


-==source==-
SQL> delete t1 where id = 2000;

8 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(*) from t1;

  COUNT(*)
----------
    110584

SQL>      

Extracting from USER1.T1 to USER1.T1:

*** Total statistics since 2015-08-18 16:31:50 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

*** Daily statistics since 2015-08-18 16:31:50 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

*** Hourly statistics since 2015-08-18 17:00:00 ***
        Total inserts                                  82944.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                               82952.00

*** Latest statistics since 2015-08-18 16:31:50 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

End of Statistics.
-==target==-

SQL> select count(*) from user2.t1hist;

  COUNT(*)
----------
    110600

SQL>
SQL> l
  1* select * from user2.t1hist where id = 2000
SQL> /

TS           BEFORE_AFTER         OP_TYPE                                          ID
------------ -------------------- ---------------------------------------- ----------
06-JAN-16    AFTER                INSERT                                         2000
06-JAN-16    AFTER                INSERT                                         2000
06-JAN-16    AFTER                INSERT                                         2000
06-JAN-16    AFTER                INSERT                                         2000
06-JAN-16    AFTER                INSERT                                         2000
06-JAN-16    AFTER                INSERT                                         2000
06-JAN-16    AFTER                INSERT                                         2000
06-JAN-16    BEFORE               DELETE                                         2000
06-JAN-16    BEFORE               DELETE                                         2000
06-JAN-16    BEFORE               DELETE                                         2000
06-JAN-16    BEFORE               DELETE                                         2000

TS           BEFORE_AFTER         OP_TYPE                                          ID
------------ -------------------- ---------------------------------------- ----------
06-JAN-16    BEFORE               DELETE                                         2000
06-JAN-16    BEFORE               DELETE                                         2000
06-JAN-16    BEFORE               DELETE                                         2000
06-JAN-16    BEFORE               DELETE                                         2000
06-JAN-16    AFTER                INSERT                                         2000

16 rows selected.

SQL> 


GGSCI (target) 23> stats *

Sending STATS request to REPLICAT REP1 ...

Start of Statistics at 2016-01-06 08:02:22.

Replicating from USER1.T1 to USER1.T1:

*** Total statistics since 2016-01-06 07:12:10 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

*** Daily statistics since 2016-01-06 07:12:10 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

*** Hourly statistics since 2016-01-06 08:00:00 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                                   8.00

*** Latest statistics since 2016-01-06 07:12:10 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

Replicating from USER1.T1 to USER2.T1HIST:

*** Total statistics since 2016-01-06 07:12:10 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

*** Daily statistics since 2016-01-06 07:12:10 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

*** Hourly statistics since 2016-01-06 08:00:00 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                                   8.00

*** Latest statistics since 2016-01-06 07:12:10 ***
        Total inserts                                 110592.00
        Total updates                                      0.00
        Total deletes                                      8.00
        Total discards                                     0.00
        Total operations                              110600.00

End of Statistics.

结论:源表中删除了8条,剩余110584条;目标表中多了16条,包括删除前和删除后的记录。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值