Setting up IBM DB2 CDC for ELT & CDC
ELT & CDC uses ASN-based change data capture for IBM DB2. Triggers on each source table write everyINSERT, UPDATE, and DELETE into a CD (Change Data) table under a dedicated CDC schema (IIO_ASN). The connector reads changes from the CD tables and deletes records it has processed.
The sync user only needs read access to your source tables. All CDC objects live in the IIO_ASN schema, so nothing is created in your source schema.
Requirements
- IBM DB2 for Linux, UNIX, and Windows (LUW) 9.7 or above. The generated setup SQL uses
CREATE OR REPLACE TRIGGER. - A dedicated sync user with
CONNECTand read access to the source and CDC schemas. - The one-time control table setup and the per-table setup SQL must be run by a user who can create objects in the database (for example, a database administrator).
Features
Setup steps
1
Create the sync user
Create the user at the operating system level on the DB2 server host:Then connect to the database and grant database access privileges:
2
Grant schema privileges
Grant the sync user read access to the source schema and to the CDC schema. Also grant delete access on the CDC schema so the connector can clean up change records it has processed:
3
Create the CDC control tables (one-time)
Run the following once per database to create the If you run DB2 for LUW with an IIDR license, you can instead use the built-in ASNCDC management user-defined functions (UDFs) and the ASN Capture agent to populate CD tables from the transaction log. The source creation wizard shows the commands for that variant.
IIO_ASN schema, the ASN control tables, and the sequence the capture triggers use. The source creation wizard shows the same SQL with your schema filled in.4
Create the source
In the Integrate.io ELT & CDC dashboard, create a new IBM DB2 source and enter the host, port (default
50000), database user, password, database, and schema. The connector supports SSH tunnel and SSL connections.5
Run the per-table setup SQL
When you select tables in the pipeline schema step, click Generate CDC Setup SQL. Integrate.io connects to your database, checks which of the selected tables already have CDC configured, and generates SQL only for the tables that still need setup.Run the generated script as a user who can create objects in the
IIO_ASN schema and create triggers on the source tables. With the DB2 command line processor:What the setup SQL creates
The generated script contains 6 statements per table:- A CD table
IIO_ASN.CD_<TABLE>that stores captured changes together with theIBMSNAP_COMMITSEQ,IBMSNAP_INTENTSEQ,IBMSNAP_OPERATION, andIBMSNAP_LOGMARKERcontrol columns. - An index on the CD table’s sequence columns.
- A
MERGEthat registers the table inIIO_ASN.IBMSNAP_REGISTER. - Three
CREATE OR REPLACE TRIGGERstatements, one each forINSERT,UPDATE, andDELETE, that copy changed rows into the CD table.
MYSCHEMA.ORDERS looks like this:
db2 -tvf).
Re-running the setup SQL
The script is safe to re-run:CREATE OR REPLACE TRIGGERre-creates each trigger atomically, so there is no window in which changes go uncaptured.- Re-running the
CREATE TABLE,CREATE INDEX, andMERGEstatements against existing objects returnsSQL0601N,SQL0605W, andSQL0100W. These codes are expected on a re-run and harmless.
Replacing a trigger that was created by a different user requires ownership of the trigger or
DBADM authority. This only matters when a different administrator re-runs the script; the sync user’s privileges are not affected.Limitations
- Table names, column names, and schema names must not contain a semicolon. SQL generation fails with an error for such identifiers because a semicolon would split the generated statement.
- IBM DB2 for i (AS/400) is a separate connector and does not use this setup.