Wednesday, October 11, 2023

Adding new tables into Replication - Assess the effect of GoldenGate 21.3 replication on triggers

 

Adding new tables into Replication (with trigger and sequence)


Table Datamodel: 2 tables with trigger managing 1 one of the tables based on another table DML (insert,update,delete).


Main table: main_tblapp01_13

Auxiliary (Trigger) managed table: arch_tblapp01_14

Other object involved: seqmain_tblapp01_13 (for inserting the primary key column value in main_tblapp01_13) & seqarch_tblapp01_14 (for inserting the primary key column value in arch_tblapp01_14)


Step 1) 


Ensure extract and replication are stopped


export OGG_HOME=/u01/app/oracle/product/21.3.0/ogg_home_1

export PATH=$PATH:$OGG_HOME/bin

adminclient

connect http://127.0.0.1:9011 deployment oggdep01 user ggsca password ggsca


using adminclient> info all


Actual output:


OGG (not connected) 1> connect http://127.0.0.1:9011 deployment oggdep01 user ggsca password ggsca


OGG (http://127.0.0.1:9011 oggdep01) 2> info all

Program     Status      Group       Type             Lag at Chkpt  Time Since Chkpt


EXTRACT     STOPPED     RXT1        INTEGRATED       00:00:00      01:02:47

REPLICAT    STOPPED     RPT1        PARALLEL NONINT  00:00:00      01:02:12

REPLICAT    STOPPED     RPT2        PARALLEL NONINT  00:00:00      00:00:00


OGG (http://127.0.0.1:9011 oggdep01) 3>



Step 2) 


Extract the lowest SCN:


set colsep ,

set lines 200

set pages 3000

col osuser for a20

col username for a20

set time on

set timing on

alter session set nls_date_format='DD/MON/YYYY HH24:MI:SS';

SELECT T.START_SCN, T.STATUS TSTATUS, T.START_DATE,

       S.SID, S.SERIAL#, S.INST_ID, S.USERNAME, S.OSUSER, S.STATUS SSTATUS, S.LOGON_TIME

  FROM gv$transaction T

 INNER JOIN gv$session S

 ON s.saddr = t.ses_addr

UNION ALL

SELECT CURRENT_SCN, 'CURRENT', CURRENT_DATE,

       NULL, NULL, NULL, 'SYS', NULL, NULL, NULL

 from v$database

ORDER BY 1;


Actual output:


 START_SCN,TSTATUS         ,START_DATE          ,       SID,   SERIAL#,   INST_ID,USERNAME            ,OSUSER              ,SSTATUS ,LOGON_TIME

----------,----------------,--------------------,----------,----------,----------,--------------------,--------------------,--------,--------------------

    710475,CURRENT         ,11/OCT/2023 18:55:45,          ,          ,          ,SYS                 ,                    ,          ,




Step 3)


Pump out the tables from source db based on the above scn


expdp directory=DATA_PUMP_DIR tables=userapp01.main_tblapp01_13,userapp01.arch_tblapp01_14 dumpfile=userapp01_subset5.dmp logfile=userapp01_subset5.log FLASHBACK_SCN=710475 logtime=ALL METRICS=YES exclude=statistics, table_statistics, index_statistics


Actual output:


11-OCT-23 18:56:57.559: W-1      Completed 1 TRIGGER objects in 0 seconds

11-OCT-23 18:56:58.427: W-1 . . exported "USERAPP01"."ARCH_TBLAPP01_14"              127.0 KB     999 rows in 0 seconds using direct_path

11-OCT-23 18:56:58.464: W-1 . . exported "USERAPP01"."MAIN_TBLAPP01_13"              114.5 KB     999 rows in 0 seconds using direct_path

11-OCT-23 18:56:58.727: W-1      Completed 2 TABLE_EXPORT/TABLE/TABLE_DATA objects in 0 seconds

11-OCT-23 18:56:59.381: W-1 Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

11-OCT-23 18:56:59.429: ******************************************************************************

11-OCT-23 18:56:59.430: Dump file set for SYS.SYS_EXPORT_TABLE_01 is:

11-OCT-23 18:56:59.437:   /u01/app/oracle/admin/GGSRC05T/dpdump/userapp01_subset5.dmp

11-OCT-23 18:56:59.466: Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Wed Oct 11 18:56:59 2023 elapsed 0 00:00:08




Step 4) 


Copy the dump over to target

and import the tables into target


impdp tables=userapp01.main_tblapp01_13,userapp01.arch_tblapp01_14 dumpfile=userapp01_subset5.dmp logfile=userapp01_subset_import5.log  directory=DATA_PUMP_DIR logtime=ALL METRICS=YES


Actual output:


11-OCT-23 18:58:15.518: W-1 . . imported "USERAPP01"."ARCH_TBLAPP01_14"              127.0 KB     999 rows in 1 seconds using direct_path

11-OCT-23 18:58:15.586: W-1 . . imported "USERAPP01"."MAIN_TBLAPP01_13"              114.5 KB     999 rows in 0 seconds using direct_path

11-OCT-23 18:58:15.646: W-1 Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

11-OCT-23 18:58:15.916: W-1      Completed 1 CONSTRAINT objects in 0 seconds

11-OCT-23 18:58:15.916: W-1 Processing object type TABLE_EXPORT/TABLE/TRIGGER

11-OCT-23 18:58:16.180: W-1      Completed 1 TRIGGER objects in 1 seconds

11-OCT-23 18:58:16.247: W-1      Completed 2 TABLE_EXPORT/TABLE/TABLE_DATA objects in 1 seconds

11-OCT-23 18:58:16.280: ORA-39082: Object type TRIGGER:"USERAPP01"."TRG_MAIN_TBLAPP01_13" created with compilation warnings


11-OCT-23 18:58:16.374: Job "SYS"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at Wed Oct 11 18:58:16 2023 elapsed 0 00:00:06


SQL> create sequence seqarch_tblapp01_14

start with 1

increment by 1

nocache

nocycle;  2    3    4    5


Sequence created.


SQL> alter trigger "USERAPP01"."TRG_MAIN_TBLAPP01_13" compile;


Trigger altered.


SQL> select status from user_objects where object_name='TRG_MAIN_TBLAPP01_13';


STATUS

-------

VALID




Step 5) 


Let us add/delete/update more records:



conn userapp01/userapp01

set time on

set timing on

set colsep ,

set lines 200

set pages 3000

col osuser for a20

col username for a20

col trigger_name for a30

col status for a10

select trigger_name,status from user_triggers;

select count(1) from arch_tblapp01_14;

select count(1) from main_tblapp01_13;


insert into main_tblapp01_13

select seqmain_tblapp01_13.nextval,mod(level,10) partid

,rpad('R',mod(level,200),'X') idstr

from dual

connect by level < 1000;


delete main_tblapp01_13 where id=5;



update main_tblapp01_13 set partid=100 where id=10;


commit;


check the record count:


select count(1) from arch_tblapp01_14;

select count(1) from main_tblapp01_13;


Actual output:


SQL> conn userapp01/userapp01

Connected.

SQL> set time on

set timing on

set colsep ,

set lines 200

set pages 3000

col osuser for a20

col username for a20

col trigger_name for a30

col status for a1019:00:00 SQL> 19:00:00 SQL> 19:00:00 SQL> 19:00:00 SQL> 19:00:00 SQL> 19:00:00 SQL> 19:00:00 SQL> 19:00:00 SQL>

19:00:01 SQL> select trigger_name,status from user_triggers;


TRIGGER_NAME                  ,STATUS

------------------------------,----------

TRG_MAIN_TBLAPP01_07          ,ENABLED

TRG_MAIN_TBLAPP01_09          ,ENABLED

TRG_MAIN_TBLAPP01_11          ,ENABLED

TRG_MAIN_TBLAPP01_13          ,ENABLED


Elapsed: 00:00:00.01

19:00:05 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

       999


Elapsed: 00:00:00.01

19:00:12 SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

       999


Elapsed: 00:00:00.00

19:00:17 SQL> insert into main_tblapp01_13

select seqmain_tblapp01_13.nextval,mod(level,10) partid

,rpad('R',mod(level,200),'X') idstr

from dual

connect by level < 1000;19:00:22   2  19:00:22   3  19:00:22   4  19:00:22   5


999 rows created.


Elapsed: 00:00:00.23

19:00:24 SQL>

19:00:28 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      1998


Elapsed: 00:00:00.00

19:00:32 SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

      1998


Elapsed: 00:00:00.00

19:00:35 SQL> delete main_tblapp01_13 where id=5;


1 row deleted.


Elapsed: 00:00:00.01

19:00:41 SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

      1997


Elapsed: 00:00:00.00

19:00:47 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      1999


Elapsed: 00:00:00.00

19:00:50 SQL> update main_tblapp01_13 set partid=100 where id=10;


1 row updated.


Elapsed: 00:00:00.00

19:01:02 SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

      1997


Elapsed: 00:00:00.00

19:01:05 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      2000


Elapsed: 00:00:00.00

19:01:08 SQL> commit;


Commit complete.


Elapsed: 00:00:00.01




Step 6) Extract start

The extract is setup @ schemalevel, so no action needed for the table we created.


export OGG_HOME=/u01/app/oracle/product/21.3.0/ogg_home_1

export PATH=$PATH:$OGG_HOME/bin

adminclient

connect http://127.0.0.1:9011 deployment oggdep01 user ggsca password ggsca

DBLOGIN USERIDALIAS ggsrc05t


info all

start extract rxt1

info extract rxt1 detail


Actual output:


OGG (http://127.0.0.1:9011 oggdep01) 3> info all

Program     Status      Group       Type             Lag at Chkpt  Time Since Chkpt


EXTRACT     STOPPED     RXT1        INTEGRATED       00:00:00      01:10:01

REPLICAT    STOPPED     RPT1        PARALLEL NONINT  00:00:00      01:09:26

REPLICAT    STOPPED     RPT2        PARALLEL NONINT  00:00:00      00:00:00


OGG (http://127.0.0.1:9011 oggdep01) 4> start extract rxt1

2023-10-11T18:02:27Z  INFO    OGG-00975  Extract group RXT1 starting.

2023-10-11T18:02:27Z  INFO    OGG-15426  Extract group RXT1 started.


OGG (http://127.0.0.1:9011 oggdep01) 5> info all

Program     Status      Group       Type             Lag at Chkpt  Time Since Chkpt


EXTRACT     RUNNING     RXT1        INTEGRATED       00:00:00      00:00:00

REPLICAT    STOPPED     RPT1        PARALLEL NONINT  00:00:00      01:09:36

REPLICAT    STOPPED     RPT2        PARALLEL NONINT  00:00:00      00:00:00


OGG (http://127.0.0.1:9011 oggdep01) 6> info extract rxt1 detail


Extract    RXT1      Last Started 2023-10-11 19:02   Status RUNNING

Checkpoint Lag       00:00:00 (updated 00:00:00 ago)

Process ID           26117

Log Read Checkpoint  Oracle Integrated Redo Logs

                     2023-10-11 19:02:36

                     SCN 0.717378 (717378)

Encryption Profile   LocalWallet


  Target Extract Trails:


  Trail Name                                       Seqno        RBA     Max MB Trail Type


  src/r1                                               4    1000423        500 EXTTRAIL



Integrated Extract outbound server first scn: 0.353578 (353578)


Integrated Extract outbound server filtering start scn: 0.353578 (353578)


  Extract Source                          Begin             End


  Not Available                           2023-10-07 18:36  2023-10-11 19:02

  Not Available                           2023-10-07 18:36  2023-10-11 17:52

  Not Available                           2023-10-07 18:36  2023-10-11 17:52

  Not Available                           2023-10-07 18:36  2023-10-11 17:52

  Not Available                           2023-10-07 18:36  2023-10-11 16:48

  Not Available                           2023-10-07 18:36  2023-10-11 16:48

  Not Available                           2023-10-07 18:36  2023-10-11 16:48

  Not Available                           2023-10-07 18:36  2023-10-11 15:06

  Not Available                           2023-10-07 18:36  2023-10-11 15:06

  Not Available                           2023-10-07 18:36  2023-10-11 15:06

  Not Available                           2023-10-07 18:36  2023-10-08 01:11

  Not Available                           2023-10-07 18:36  2023-10-08 01:11

  Not Available                           2023-10-07 18:36  2023-10-08 01:11

  Not Available                           * Initialized *   2023-10-07 18:36

  Not Available                           * Initialized *   2023-10-07 18:36

  Not Available                           * Initialized *   2023-10-07 18:36



Current directory    /


Report file          /oggdata/oggdep01/var/lib/report/RXT1.rpt

Parameter file       /oggdata/oggdep01/etc/conf/ogg/rxt1.prm

Checkpoint file      /oggdata/oggdep01/var/lib/checkpt/RXT1.cpe

Process file         /oggdata/oggdep01/var/run/RXT1.pce

Error log            /oggdata/oggdep01/var/log/ggserr.log


OGG (http://127.0.0.1:9011 oggdep01) 7>




Step 7) Add the table to replicat param with handlecollision


export OGG_HOME=/u01/app/oracle/product/21.3.0/ogg_home_1

export PATH=$PATH:$OGG_HOME/bin

adminclient

connect http://127.0.0.1:9011 deployment oggdep01 user ggsca password ggsca

DBLOGIN USERIDALIAS ggtgt06t

info replicat rpt1 detail


vi /oggdata/oggdep01/etc/conf/ogg/rpt1.prm


-- dboptions suppresstriggers;

MAP userapp01.main_tblapp01_13, target userapp01.main_tblapp01_13,  HANDLECOLLISIONS;

MAP userapp01.arch_tblapp01_14, target userapp01.arch_tblapp01_14,  HANDLECOLLISIONS;


actual file:


OGG (http://127.0.0.1:9011 oggdep01) 10> view params rpt1

REPLICAT rpt1

USERIDALIAS ggtgt06t DOMAIN OracleGoldenGate

--DDL EXCLUDE ALL

DDLERROR default discard

REPERROR (default,discard)

DDLOPTIONS REPORT

MAP userapp01.tblapp01_01, target userapp01.tblapp01_01,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);

MAP userapp01.tblapp01_02, target userapp01.tblapp01_02,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);

MAP userapp01.main_tblapp01_07, target userapp01.main_tblapp01_07;

MAP userapp01.arch_tblapp01_08, target userapp01.arch_tblapp01_08;

MAP userapp01.main_tblapp01_09, target userapp01.main_tblapp01_09;

MAP userapp01.arch_tblapp01_10, target userapp01.arch_tblapp01_10;

MAP userapp01.main_tblapp01_11, target userapp01.main_tblapp01_11;

MAP userapp01.arch_tblapp01_12, target userapp01.arch_tblapp01_12;

MAP userapp01.main_tblapp01_13, target userapp01.main_tblapp01_13,  HANDLECOLLISIONS;

MAP userapp01.arch_tblapp01_14, target userapp01.arch_tblapp01_14,  HANDLECOLLISIONS;

-- MAP userapp01.tblapp01_03, target userapp01.tblapp01_03,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);

-- MAP userapp01.tblapp01_04, target userapp01.tblapp01_04,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);


OGG (http://127.0.0.1:9011 oggdep01) 11>




Step 8) ensure the permission below is granted the goldengate user in target db


  Alias: ggtgt06t

  Userid: rggadmin@//192.168.194.11:1521/GGTGT06T



exec dbms_goldengate_auth.grant_admin_privilege('rggadmin');


Actual output:


This isnt needed if we arent going to use "DBOPTIONS SUPPRESSTRIGGERS"


Step 9)  Verify and start the replication


export OGG_HOME=/u01/app/oracle/product/21.3.0/ogg_home_1

export PATH=$PATH:$OGG_HOME/bin

adminclient

connect http://127.0.0.1:9011 deployment oggdep01 user ggsca password ggsca

DBLOGIN USERIDALIAS ggtgt06t


info replicat RPT1

start replicat RPT1

status replicat RPT1

info all


Actual output:


OGG (http://127.0.0.1:9011 oggdep01) 11> info replicat RPT1


Replicat   RPT1      Last Started 2023-10-11 17:43   Status STOPPED

Parallel

Checkpoint Lag       00:00:00 (updated 01:12:55 ago)

Log Read Checkpoint  File src/r1000000003

                     2023-10-11 17:52:55.191445  RBA 985919

Encryption Profile   LocalWallet


OGG (http://127.0.0.1:9011 oggdep01) 12>


OGG (http://127.0.0.1:9011 oggdep01) 12>


OGG (http://127.0.0.1:9011 oggdep01) 12> info replicat rpt1 detail


Replicat   RPT1      Last Started 2023-10-11 17:43   Status STOPPED

Parallel

Checkpoint Lag       00:00:00 (updated 01:13:03 ago)

Log Read Checkpoint  File src/r1000000003

                     2023-10-11 17:52:55.191445  RBA 985919

Encryption Profile   LocalWallet


Current Log BSN value: 696581



Low Watermark CSN value: 696605



High Watermark CSN value: 696605




Current directory    /


Report file          /oggdata/oggdep01/var/lib/report/RPT1.rpt

Parameter file       /oggdata/oggdep01/etc/conf/ogg/rpt1.prm

Checkpoint file      /oggdata/oggdep01/var/lib/checkpt/RPT1.cpr

Checkpoint table     rggadmin.ggs_checkpoint

Process file         /oggdata/oggdep01/var/run/RPT1.pcr

Error log            /oggdata/oggdep01/var/log/ggserr.log


OGG (http://127.0.0.1:9011 oggdep01) 13> start replicat RPT1

2023-10-11T18:06:33Z  INFO    OGG-00975  Replicat group RPT1 starting.

2023-10-11T18:06:33Z  INFO    OGG-15445  Replicat group RPT1 started.


OGG (http://127.0.0.1:9011 oggdep01) 14> status replicat RPT1

REPLICAT RPT1: RUNNING


OGG (http://127.0.0.1:9011 oggdep01) 15> info all

Program     Status      Group       Type             Lag at Chkpt  Time Since Chkpt


EXTRACT     RUNNING     RXT1        INTEGRATED       00:00:00      00:00:03

REPLICAT    RUNNING     RPT1        PARALLEL NONINT  00:00:00      00:00:03

REPLICAT    STOPPED     RPT2        PARALLEL NONINT  00:00:00      00:00:00


OGG (http://127.0.0.1:9011 oggdep01) 16> DBLOGIN USERIDALIAS ggtgt06t

Successfully logged into database.


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 17> lag replicat rpt1


LAG                 AGE                 FROM                TO                  PATH

5.88s               26.14s              GGSRC05T            GGTGT06T            RXT1 ==> RPT1


Sending GETLAG request to Replicat group RPT1 ...


Low watermark lag: 25 seconds

High watermark lag: 24 seconds

At EOF, no more records to process


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 18>



Step 10) check lag


lag replicat rpt1

lag reaches EOF


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 19> lag replicat rpt1


LAG                 AGE                 FROM                TO                  PATH

4.88s               28.44s              GGSRC05T            GGTGT06T            RXT1 ==> RPT1


Sending GETLAG request to Replicat group RPT1 ...


Low watermark lag: 27 seconds

High watermark lag: 27 seconds

At EOF, no more records to process


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 20>




Step 11) stop replicat & remove the handlecollisions param


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 21> status replicat RPT1

REPLICAT RPT1: STOPPED


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 22> view params rpt1

REPLICAT rpt1

USERIDALIAS ggtgt06t DOMAIN OracleGoldenGate

--DDL EXCLUDE ALL

DDLERROR default discard

REPERROR (default,discard)

DDLOPTIONS REPORT

MAP userapp01.tblapp01_01, target userapp01.tblapp01_01,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);

MAP userapp01.tblapp01_02, target userapp01.tblapp01_02,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);

MAP userapp01.main_tblapp01_07, target userapp01.main_tblapp01_07;

MAP userapp01.arch_tblapp01_08, target userapp01.arch_tblapp01_08;

MAP userapp01.main_tblapp01_09, target userapp01.main_tblapp01_09;

MAP userapp01.arch_tblapp01_10, target userapp01.arch_tblapp01_10;

MAP userapp01.main_tblapp01_11, target userapp01.main_tblapp01_11;

MAP userapp01.arch_tblapp01_12, target userapp01.arch_tblapp01_12;

MAP userapp01.main_tblapp01_13, target userapp01.main_tblapp01_13;

MAP userapp01.arch_tblapp01_14, target userapp01.arch_tblapp01_14;

-- MAP userapp01.tblapp01_03, target userapp01.tblapp01_03,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);

-- MAP userapp01.tblapp01_04, target userapp01.tblapp01_04,  FILTER ( @GETENV('TRANSACTION', 'CSN') > 410419);


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 23>




Step 12) start replicat


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 23> start replicat RPT1

2023-10-11T18:13:27Z  INFO    OGG-00975  Replicat group RPT1 starting.

2023-10-11T18:13:27Z  INFO    OGG-15445  Replicat group RPT1 started.


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 24> status replicat RPT1

REPLICAT RPT1: RUNNING


OGG (http://127.0.0.1:9011 oggdep01 as ggtgt06t@GGTGT06T) 25>



Further test:

Overall result:


Source:


19:01:30 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      2000


Elapsed: 00:00:00.00

19:08:49 SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

      1997


Elapsed: 00:00:00.00

19:08:55 SQL> select count(1) from main_tblapp01_13 where id=1;


  COUNT(1)

----------

         1


Elapsed: 00:00:00.00

19:14:58 SQL> select count(1) from main_tblapp01_13 where id=1001;


  COUNT(1)

----------

         1


Elapsed: 00:00:00.00

19:15:05 SQL> select count(1) from arch_tblapp01_14 where id=1;


  COUNT(1)

----------

         1


Elapsed: 00:00:00.01

19:15:14 SQL> select count(1) from arch_tblapp01_14 where id=1001;


  COUNT(1)

----------

         1


Elapsed: 00:00:00.01

19:15:21 SQL> update main_tblapp01_13 set partid=100 where id=1001;


1 row updated.


Elapsed: 00:00:00.00

19:15:40 SQL> select count(1) from arch_tblapp01_14 where id=1001;


  COUNT(1)

----------

         2


Elapsed: 00:00:00.00

19:15:45 SQL> commit;


Commit complete.


Elapsed: 00:00:00.01

19:16:02 SQL> select count(1) from arch_tblapp01_14 where id=1;


  COUNT(1)

----------

         1


Elapsed: 00:00:00.00

19:16:42 SQL> select count(1) from main_tblapp01_13 where id=1001;


  COUNT(1)

----------

         1


Elapsed: 00:00:00.00

19:16:50 SQL> set lines 200

19:18:15 SQL> set pages 3000

19:18:18 SQL> set colsep ,

19:18:21 SQL> alter session set nls_Date_format='DD/MON/YYYY HH24:MI:SS';


Session altered.


Elapsed: 00:00:00.00

19:18:28 SQL> col idstr for a20

19:18:33 SQL> select * from arch_tblapp01_14 where id=1001;


TSTMP               ,      UNID,        ID,    PARTID,IDSTR

--------------------,----------,----------,----------,--------------------

11/OCT/2023 19:00:24,      1001,      1001,         2,RX

11/OCT/2023 19:15:40,      2001,      1001,       100,RX


Elapsed: 00:00:00.01

19:18:36 SQL> select count(1) from main_tblapp01_13 where id=1002;


  COUNT(1)

----------

         1


Elapsed: 00:00:00.01

19:19:29 SQL> select * from arch_tblapp01_14 where id=1002;


TSTMP               ,      UNID,        ID,    PARTID,IDSTR

--------------------,----------,----------,----------,--------------------

11/OCT/2023 19:00:24,      1002,      1002,         3,RXX


Elapsed: 00:00:00.00

19:19:47 SQL> delete main_tblapp01_13 where id=1002;


1 row deleted.


Elapsed: 00:00:00.01

19:19:59 SQL> commit;


Commit complete.


Elapsed: 00:00:00.01

19:20:03 SQL> select * from arch_tblapp01_14 where id=1002;


TSTMP               ,      UNID,        ID,    PARTID,IDSTR

--------------------,----------,----------,----------,--------------------

11/OCT/2023 19:00:24,      1002,      1002,         3,RXX

11/OCT/2023 19:19:59,      2002,      1002,         3,RXX


Elapsed: 00:00:00.00

19:20:06 SQL> select count(1) from main_tblapp01_13 where id=1002;


  COUNT(1)

----------

         0


Elapsed: 00:00:00.00

19:20:14 SQL> col sequence_name for a30

19:21:36 SQL> col sequence_owner for a30

19:21:47 SQL> select * from user_sequences order by 1;


SEQUENCE_NAME                 , MIN_VALUE, MAX_VALUE,INCREMENT_BY,C,O,CACHE_SIZE,LAST_NUMBER,S,E,S,K

------------------------------,----------,----------,------------,-,-,----------,-----------,-,-,-,-

SEQAPP01_01                   ,         1,1.0000E+28,           1,N,N,         0,       3997,N,N,N,N

SEQAPP01_02                   ,         1,1.0000E+28,           1,N,N,         0,       3997,N,N,N,N

SEQARCH_TBLAPP01_10           ,         1,1.0000E+28,           1,N,N,         0,       3002,N,N,N,N

SEQARCH_TBLAPP01_12           ,         1,1.0000E+28,           1,N,N,         0,       2002,N,N,N,N

SEQARCH_TBLAPP01_14           ,         1,1.0000E+28,           1,N,N,         0,       2003,N,N,N,N

SEQMAIN_TBLAPP01_07           ,         1,1.0000E+28,           1,N,N,         0,       2998,N,N,N,N

SEQMAIN_TBLAPP01_09           ,         1,1.0000E+28,           1,N,N,         0,       1999,N,N,N,N

SEQMAIN_TBLAPP01_11           ,         1,1.0000E+28,           1,N,N,         0,       1999,N,N,N,N

SEQMAIN_TBLAPP01_13           ,         1,1.0000E+28,           1,N,N,         0,       1999,N,N,N,N


9 rows selected.


Elapsed: 00:00:00.01

19:22:08 SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

      1996


Elapsed: 00:00:00.00

19:22:59 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      2002


Elapsed: 00:00:00.00

19:23:13 SQL> insert into main_tblapp01_13

select seqmain_tblapp01_13.nextval,mod(level,10) partid

,rpad('R',mod(level,200),'X') idstr

from dual

connect by level < 1019:23:17   2  19:23:17   3  19:23:17   4  19:23:17   5  ;


9 rows created.


Elapsed: 00:00:00.01

19:23:18 SQL> commit;


Commit complete.


Elapsed: 00:00:00.00

19:23:25 SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

      2005


Elapsed: 00:00:00.00

19:23:29 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      2011


Elapsed: 00:00:00.00

19:23:37 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      2011


Elapsed: 00:00:00.00

19:23:38 SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      2011


Elapsed: 00:00:00.00

19:23:42 SQL> with t as

(

select id,count(1) cnt from arch_tblapp01_14 group by id

)

select id,cnt from t where cnt > 1

/19:25:30   2  19:25:30   3  19:25:30   4  19:25:30   5  19:25:30   6


        ID,       CNT

----------,----------

         5,         2

      1001,         2

      1002,         2

        10,         2


Elapsed: 00:00:00.01

19:25:31 SQL> with t as

(

select id,count(1) cnt from arch_tblapp01_14 group by id

)

select id,cnt from t where cnt > 1

order by 1

/19:25:46   2  19:25:46   3  19:25:46   4  19:25:46   5  19:25:46   6  19:25:46   7


        ID,       CNT

----------,----------

         5,         2

        10,         2

      1001,         2

      1002,         2


Elapsed: 00:00:00.01

19:25:47 SQL>




TGT:


SQL> col idstr for a20

SQL> select * from arch_tblapp01_14 where id=10001;


no rows selected


SQL>

SQL> select * from arch_tblapp01_14 where id=1001;


TSTMP               ,      UNID,        ID,    PARTID,IDSTR

--------------------,----------,----------,----------,--------------------

11/OCT/2023 19:00:24,      1001,      1001,         2,RX

11/OCT/2023 19:15:40,      2001,      1001,       100,RX


SQL> select count(1) from main_tblapp01_13 where id=1002;


  COUNT(1)

----------

         1


SQL> select * from arch_tblapp01_14 where id=1002;


TSTMP               ,      UNID,        ID,    PARTID,IDSTR

--------------------,----------,----------,----------,--------------------

11/OCT/2023 19:00:24,      1002,      1002,         3,RXX


SQL> select count(1) from main_tblapp01_13 where id=1002;


  COUNT(1)

----------

         0


SQL> select * from arch_tblapp01_14 where id=1002;


TSTMP               ,      UNID,        ID,    PARTID,IDSTR

--------------------,----------,----------,----------,--------------------

11/OCT/2023 19:00:24,      1002,      1002,         3,RXX

11/OCT/2023 19:19:59,      2002,      1002,         3,RXX


SQL> col sequence_name for a30

SQL> col sequence_owner for a30

SQL> select * from user_sequences order by 2;


SEQUENCE_NAME                 , MIN_VALUE, MAX_VALUE,INCREMENT_BY,C,O,CACHE_SIZE,LAST_NUMBER,S,E,S,S,K

------------------------------,----------,----------,------------,-,-,----------,-----------,-,-,-,-,-

SEQARCH_TBLAPP01_10           ,         1,1.0000E+28,           1,N,N,         0,          1,N,N,N,N,N

SEQARCH_TBLAPP01_14           ,         1,1.0000E+28,           1,N,N,         0,          1,N,N,N,N,N

SEQARCH_TBLAPP01_12           ,         1,1.0000E+28,           1,N,N,         0,          1,N,N,N,N,N


SQL> select * from user_sequences order by 1;


SEQUENCE_NAME                 , MIN_VALUE, MAX_VALUE,INCREMENT_BY,C,O,CACHE_SIZE,LAST_NUMBER,S,E,S,S,K

------------------------------,----------,----------,------------,-,-,----------,-----------,-,-,-,-,-

SEQARCH_TBLAPP01_10           ,         1,1.0000E+28,           1,N,N,         0,          1,N,N,N,N,N

SEQARCH_TBLAPP01_12           ,         1,1.0000E+28,           1,N,N,         0,          1,N,N,N,N,N

SEQARCH_TBLAPP01_14           ,         1,1.0000E+28,           1,N,N,         0,          1,N,N,N,N,N


SQL> select count(1) from main_tblapp01_13;


  COUNT(1)

----------

      2005


SQL> select count(1) from arch_tblapp01_14;


  COUNT(1)

----------

      2012


  1  with t as

  2  (

  3  select id,count(1) cnt from arch_tblapp01_14 group by id

  4  )

  5  select id,cnt from t where cnt > 1

  6* order by 1

SQL> /


        ID,       CNT

----------,----------

         1,         2 << Handlecollision issue

         5,         2

        10,         2

      1001,         2

      1002,         2


SQL>




Replication works – YES


Like we saw: 

handlecollision needs Primary Key (PK) or Not Null Unique Constraint

https://docs.oracle.com/en/middleware/goldengate/core/19.1/reference/handlecollisions-nohandlecollisions.html#GUID-D5A23DE0-9B9F-4497-AF74-30439D55B807

Triggers are disabled by default by the GoldenGate replication.

https://docs.oracle.com/en/middleware/goldengate/core/21.3/reference/dboptions-19.1.html#GUID-BA8C0CED-D87F-4106-862E-4AD22D910160


Flashback data archive steps

 Objective: Ways to track DML changes in a table Detailed objective: We should be able to track the changes in the table at any point in tim...