Independent senior database engineering · Pittsburgh, PAsbajwa@bajwaconsulting.com

Oracle GoldenGate Migration: Initial Load at an SCN with Data Pump

Step-by-step: start Extract, export with Data Pump at a recorded SCN, and start Replicat with AFTERCSN so no transaction is lost or applied twice.

By Sandeep Bajwa · November 24, 2026

Moving an Oracle database with Oracle GoldenGate usually comes down to one question: how do you copy the existing data and then switch to live replication without losing a transaction or applying one twice?

The answer is a System Change Number (SCN). You take the initial copy as of one exact SCN, then tell Replicat to apply only the changes that came after it. This tutorial walks through that pattern step by step, from preparing the source to proving the target is in sync.

It is a practice walkthrough. Run it in a lab before you try it anywhere near production.

What you need

  • A source Oracle database (19c or later) and a target Oracle database. In this example the target runs on Amazon EC2.
  • Oracle GoldenGate with a deployment that can reach both databases.
  • A sample schema. Here it is called SHOP, with CUSTOMERS and ORDERS tables.
  • A user with DBA privileges on both databases.

Host names, passwords and process names below are examples. Replace them with your own.

How the pieces fit together

Source Oracle --(redo)--> Extract ESHOP --(trail)--> Replicat RSHOP --> Target Oracle
      |                                                                      ^
      +----------- Data Pump export AS OF SCN  ---->  Data Pump import ------+

Extract captures every change from the moment it starts. Data Pump copies the existing rows as of one SCN. Replicat then skips everything up to and including that SCN, so each change is applied exactly once.

Step 1: Prepare the source database

GoldenGate reads changes from the redo stream, so the source needs archive logging, force logging and supplemental logging. Connect to the root container as SYSDBA:

-- Check the current settings
SELECT log_mode, force_logging, supplemental_log_data_min FROM v$database;

-- If the database is not in ARCHIVELOG mode
SHUTDOWN IMMEDIATE
STARTUP MOUNT
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;

ALTER DATABASE FORCE LOGGING;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
ALTER SYSTEM SET enable_goldengate_replication = TRUE SCOPE = BOTH;
ALTER SYSTEM SWITCH LOGFILE;

Then create a GoldenGate administration user on the source and the target, and grant it the GoldenGate privileges with DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE. Store the credentials in the GoldenGate credential store, so no password appears in a parameter file:

ALTER CREDENTIALSTORE ADD USER c##ggadmin@SRC_CDB ALIAS src_cdb
ALTER CREDENTIALSTORE ADD USER ggadmin@TGT_PDB  ALIAS tgt_pdb

Step 2: Turn on schema-level logging

Log in to the source and add supplemental logging for the whole schema. This also covers tables you create later:

DBLOGIN USERIDALIAS src_cdb
ADD SCHEMATRANDATA FREEPDB1.SHOP ALLCOLS

Step 3: Start Extract before you copy anything

This order matters. Extract must be running before you choose the SCN. If it starts afterwards, changes made in between are never captured.

The Extract parameter file, ESHOP.prm:

EXTRACT ESHOP
USERIDALIAS src_cdb
EXTTRAIL es
SOURCECATALOG FREEPDB1
TABLE SHOP.*;

Register and start it:

REGISTER EXTRACT ESHOP DATABASE CONTAINER (FREEPDB1)
ADD EXTRACT ESHOP, INTEGRATED TRANLOG, BEGIN NOW
ADD EXTTRAIL es, EXTRACT ESHOP
START EXTRACT ESHOP
INFO EXTRACT ESHOP

Wait until INFO shows the Extract as RUNNING.

Step 4: Check for long-running transactions

A transaction that started before Extract and is still open can be partly missed. Before you take the SCN, make sure no such transaction remains:

SELECT s.sid, s.username, t.start_time, t.start_scn
FROM   v$transaction t JOIN v$session s ON s.saddr = t.ses_addr
ORDER  BY t.start_scn;

Every open transaction should have started after Extract did. If an older one is still open, wait for it to finish, or ask its owner to commit or roll back.

Step 5: Record the SCN and export as of that SCN

SELECT current_scn FROM v$database;
-- Example result: 4815162

Write that number down. It is the hand-off point between the copy and the live replication. Now export the schema as of exactly that SCN:

expdp system@FREEPDB1 schemas=SHOP directory=DATA_PUMP_DIR \
      dumpfile=shop_%U.dmp logfile=shop_exp.log \
      flashback_scn=4815162

FLASHBACK_SCN gives you a consistent copy as of that moment, even while users keep changing data. Make sure the undo retention is long enough to cover the whole export, or it can fail with ORA-01555.

To prove the point in a lab, update a row on the source while the export runs. The export will not contain the change, but Extract will capture it.

Step 6: Import on the target

Copy the dump files to the target host (in this example through a private S3 bucket), check their checksums, and import:

impdp system@TGT_PDB schemas=SHOP directory=DATA_PUMP_DIR \
      dumpfile=shop_%U.dmp logfile=shop_imp.log

Do not let any application write to the target schema yet. Replicat should be the only process changing it.

Step 7: Start Replicat after the SCN

Create a checkpoint table on the target, then the Replicat parameter file, RSHOP.prm:

DBLOGIN USERIDALIAS tgt_pdb
ADD CHECKPOINTTABLE ggadmin.ggs_checkpoint
REPLICAT RSHOP
USERIDALIAS tgt_pdb
MAP FREEPDB1.SHOP.*, TARGET SHOP.*;

Add it and start it after the SCN you recorded:

ADD REPLICAT RSHOP, INTEGRATED, EXTTRAIL es, CHECKPOINTTABLE ggadmin.ggs_checkpoint
START REPLICAT RSHOP, AFTERCSN 4815162

AFTERCSN tells Replicat to skip every transaction committed at or before SCN 4815162, because those rows are already in the import. Everything after it is applied. You do not need HANDLECOLLISIONS, which can hide real data problems.

Step 8: Test and confirm

Make a few changes on the source:

INSERT INTO shop.customers (customer_id, name) VALUES (99001, 'GG Test');
UPDATE shop.orders SET status = 'SHIPPED' WHERE order_id = 1001;
DELETE FROM shop.orders WHERE order_id = 1002;
COMMIT;

Check that both processes are healthy and keeping up:

INFO ALL
LAG EXTRACT ESHOP
LAG REPLICAT RSHOP
STATS REPLICAT RSHOP, TOTAL

Then query the target. The new customer should be there, order 1001 should be SHIPPED, and order 1002 should be gone. Finally, compare row counts and totals between source and target. They should match exactly.

Common mistakes

  • Starting Extract after taking the SCN. Changes made in the gap are lost.
  • Ignoring open transactions. A transaction that began before Extract can be partly missed.
  • Using HANDLECOLLISIONS as a shortcut. It hides duplicate and missing rows instead of preventing them.
  • Writing to the target before cut-over. Replicat then runs into conflicts it should never have seen.
  • Short undo retention. A long export fails with ORA-01555: snapshot too old.

Summary

The SCN is what makes a GoldenGate migration safe. Start Extract first, copy the data as of one recorded SCN, and start Replicat after that SCN. Each change is then applied exactly once, and you can move a busy database with only a short cut-over at the end.

This walkthrough is based on Lab 5 of my book, AWS for Database Administrators: From On-Premises to Cloud. The complete lab scripts are free on GitHub at github.com/sbajwa55/aws-for-dbas-labs.

Want more? Read more DBA tutorials and troubleshooting notes on my blog, Oracle DBA Trench.

Planning a GoldenGate migration? Bajwa Consulting Services helps teams plan and run Oracle GoldenGate replication and near-zero-downtime migrations. See the GoldenGate service or get in touch.