INSERTDELETES&NOINSERTDELETES--GoldenGate Parameter

東北胖子發表於2016-05-22

SERTDELETES | 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

也就是說:此引數可以使得目標表中插入源表中被刪除的記錄,多用於業務跟蹤或審計。請參考以下測試:

  1. -==source==-  
  2. SQL> desc t1  
  3.  Name                                      Null?    Type  
  4.  ----------------------------------------- -------- ----------------------------  
  5.  ID                                                 NUMBER  
  6.   
  7. SQL>   
  8.   
  9. extract ext1  
  10. extract pum1  
  11. -==target==-  
  12.   
  13. SQL> desc user2.t1hist  
  14.  Name                                      Null?    Type  
  15.  ----------------------------------------- -------- ----------------------------  
  16.  TS                                                 DATE  
  17.  BEFORE_AFTER                                       VARCHAR2(200)  
  18.  OP_TYPE                                            VARCHAR2(20)  
  19.  ID                                                 NUMBER  
  20.   
  21. SQL>  
  22. SQL> truncate table user2.t1hist;  
  23.   
  24. Table truncated.  
  25.   
  26. SQL>   
  27.   
  28. replicat rep1  
  29. :::  
  30. MAP user1.*, TARGET user1.*;  
  31. INSERTDELETES  
  32. MAP user1.t1, TARGET user2.t1hist,  
  33. COLMAP (TS = @GETENV ("GGHEADER""COMMITTIMESTAMP"),  
  34. BEFORE_AFTER = @GETENV ("GGHEADER""BEFOREAFTERINDICATOR"),  
  35. OP_TYPE = @GETENV ("GGHEADER""OPTYPE"),  
  36. ID = ID);  
  37.   
  38.   
  39. -==source==-  
  40. SQL> delete t1 where id = 2000;  
  41.   
  42. rows deleted.  
  43.   
  44. SQL> commit;  
  45.   
  46. Commit complete.  
  47.   
  48. SQL> select count(*) from t1;  
  49.   
  50.   COUNT(*)  
  51. ----------  
  52.     110584  
  53.   
  54. SQL>        
  55.   
  56. Extracting from USER1.T1 to USER1.T1:  
  57.   
  58. *** Total statistics since 2015-08-18 16:31:50 ***  
  59.         Total inserts                                 110592.00  
  60.         Total updates                                      0.00  
  61.         Total deletes                                      8.00  
  62.         Total discards                                     0.00  
  63.         Total operations                              110600.00  
  64.   
  65. *** Daily statistics since 2015-08-18 16:31:50 ***  
  66.         Total inserts                                 110592.00  
  67.         Total updates                                      0.00  
  68.         Total deletes                                      8.00  
  69.         Total discards                                     0.00  
  70.         Total operations                              110600.00  
  71.   
  72. *** Hourly statistics since 2015-08-18 17:00:00 ***  
  73.         Total inserts                                  82944.00  
  74.         Total updates                                      0.00  
  75.         Total deletes                                      8.00  
  76.         Total discards                                     0.00  
  77.         Total operations                               82952.00  
  78.   
  79. *** Latest statistics since 2015-08-18 16:31:50 ***  
  80.         Total inserts                                 110592.00  
  81.         Total updates                                      0.00  
  82.         Total deletes                                      8.00  
  83.         Total discards                                     0.00  
  84.         Total operations                              110600.00  
  85.   
  86. End of Statistics.  
  87. -==target==-  
  88.   
  89. SQL> select count(*) from user2.t1hist;  
  90.   
  91.   COUNT(*)  
  92. ----------  
  93.     110600  
  94.   
  95. SQL>  
  96. SQL> l  
  97.   1* select * from user2.t1hist where id = 2000  
  98. SQL> /  
  99.   
  100. TS           BEFORE_AFTER         OP_TYPE                                          ID  
  101. ------------ -------------------- ---------------------------------------- ----------  
  102. 06-JAN-16    AFTER                INSERT                                         2000  
  103. 06-JAN-16    AFTER                INSERT                                         2000  
  104. 06-JAN-16    AFTER                INSERT                                         2000  
  105. 06-JAN-16    AFTER                INSERT                                         2000  
  106. 06-JAN-16    AFTER                INSERT                                         2000  
  107. 06-JAN-16    AFTER                INSERT                                         2000  
  108. 06-JAN-16    AFTER                INSERT                                         2000  
  109. 06-JAN-16    BEFORE               DELETE                                         2000  
  110. 06-JAN-16    BEFORE               DELETE                                         2000  
  111. 06-JAN-16    BEFORE               DELETE                                         2000  
  112. 06-JAN-16    BEFORE               DELETE                                         2000  
  113.   
  114. TS           BEFORE_AFTER         OP_TYPE                                          ID  
  115. ------------ -------------------- ---------------------------------------- ----------  
  116. 06-JAN-16    BEFORE               DELETE                                         2000  
  117. 06-JAN-16    BEFORE               DELETE                                         2000  
  118. 06-JAN-16    BEFORE               DELETE                                         2000  
  119. 06-JAN-16    BEFORE               DELETE                                         2000  
  120. 06-JAN-16    AFTER                INSERT                                         2000  
  121.   
  122. 16 rows selected.  
  123.   
  124. SQL>   
  125.   
  126.   
  127. GGSCI (target) 23> stats *  
  128.   
  129. Sending STATS request to REPLICAT REP1 ...  
  130.   
  131. Start of Statistics at 2016-01-06 08:02:22.  
  132.   
  133. Replicating from USER1.T1 to USER1.T1:  
  134.   
  135. *** Total statistics since 2016-01-06 07:12:10 ***  
  136.         Total inserts                                 110592.00  
  137.         Total updates                                      0.00  
  138.         Total deletes                                      8.00  
  139.         Total discards                                     0.00  
  140.         Total operations                              110600.00  
  141.   
  142. *** Daily statistics since 2016-01-06 07:12:10 ***  
  143.         Total inserts                                 110592.00  
  144.         Total updates                                      0.00  
  145.         Total deletes                                      8.00  
  146.         Total discards                                     0.00  
  147.         Total operations                              110600.00  
  148.   
  149. *** Hourly statistics since 2016-01-06 08:00:00 ***  
  150.         Total inserts                                      0.00  
  151.         Total updates                                      0.00  
  152.         Total deletes                                      8.00  
  153.         Total discards                                     0.00  
  154.         Total operations                                   8.00  
  155.   
  156. *** Latest statistics since 2016-01-06 07:12:10 ***  
  157.         Total inserts                                 110592.00  
  158.         Total updates                                      0.00  
  159.         Total deletes                                      8.00  
  160.         Total discards                                     0.00  
  161.         Total operations                              110600.00  
  162.   
  163. Replicating from USER1.T1 to USER2.T1HIST:  
  164.   
  165. *** Total statistics since 2016-01-06 07:12:10 ***  
  166.         Total inserts                                 110592.00  
  167.         Total updates                                      0.00  
  168.         Total deletes                                      8.00  
  169.         Total discards                                     0.00  
  170.         Total operations                              110600.00  
  171.   
  172. *** Daily statistics since 2016-01-06 07:12:10 ***  
  173.         Total inserts                                 110592.00  
  174.         Total updates                                      0.00  
  175.         Total deletes                                      8.00  
  176.         Total discards                                     0.00  
  177.         Total operations                              110600.00  
  178.   
  179. *** Hourly statistics since 2016-01-06 08:00:00 ***  
  180.         Total inserts                                      0.00  
  181.         Total updates                                      0.00  
  182.         Total deletes                                      8.00  
  183.         Total discards                                     0.00  
  184.         Total operations                                   8.00  
  185.   
  186. *** Latest statistics since 2016-01-06 07:12:10 ***  
  187.         Total inserts                                 110592.00  
  188.         Total updates                                      0.00  
  189.         Total deletes                                      8.00  
  190.         Total discards                                     0.00  
  191.         Total operations                              110600.00  
  192.   
  193. End of Statistics.  
結論:源表中刪除了8條,剩餘110584條;目標表中多了16條,包括刪除前和刪除後的記錄。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2317695/viewspace-2105021/,如需轉載,請註明出處,否則將追究法律責任。

相關文章