Creating Q subscriptions for unidirectional replication

By creating Q subscriptions for unidirectional replication, you define how data from source tables is replicated to target tables or is passed to parameters in a stored procedure for data manipulation.

Before you begin

  • Plan how you want to group replication queue maps and Q subscriptions.
  • Create the control tables for the Q Capture program in the server that contains the source table for the Q subscription.
  • Create the control tables for the Q Apply program in the server that contains the target for the Q subscription.
  • Specify the queues for replicating and their attributes by creating a replication queue map. (You can do this task before you create a Q subscription or while you create a Q subscription.)
  • Prepare the stored procedure if you want the Q Apply program to pass source changes to a stored procedure instead of to a target table.

Restrictions

  • Views cannot be sources or targets for Q subscriptions.
  • Identity columns in the target table cannot be defined as GENERATED ALWAYS.

z/OS

  • Do not select ROWID columns for replication except when the ROWID column is the only unique index that is specified for replication. Replication of ROWID columns is not supported for bidirectional or peer-to-peer replication.
    Recommendation: Use an identity column rather than a ROWID column as the unique index for replication.
    If you are replicating LOB columns, you must have an unique index besides the ROWID unique index.

Linux, UNIX, Windows

  • Replication is supported from multiple-partition databases. There is no limit to the number of partitions that replication supports.
  • Replication is supported from tables that use value compression or row compression. DB2® uncompresses log records before passing them to the Q Capture program. The data is passed uncompressed from source to target and the target does not need to have compression set.
  • Replication is supported from materialized query tables (MQTs).

Procedure

To create a Q subscription for unidirectional replication from one source table to one target table or stored procedure, use one of the following methods:
Method Description
ASNCLP command-line program Use the CREATE QSUB command. For example, the following commands set the environment and create a Q subscription for unidirectional replication, EMPLOYEE0001, with the following characteristics:
  • The replication queue map is SAMPLE_ASN1_TO_TARGETDB_ASN1.
  • The Q Apply program loads the target tables using the EXPORT and IMPORT utilities.
  • The EMPNO column is used as the key column for replication to determine the uniqueness of a row.
ASNCLP SESSION SET TO Q REPLICATION;
SET SERVER CAPTURE TO DB SAMPLE;
SET CAPTURE SCHEMA SOURCE ASN1;
SET SERVER TARGET TO DB TARGET;
SET APPLY SCHEMA ASN1;
SET RUN SCRIPT LATER;

CREATE QSUB USING REPLQMAP
SAMPLE_ASN1_TO_TARGETDB_ASN1
(SUBNAME EMPLOYEE0001 EMPLOYEE OPTIONS
HAS LOAD PHASE I TARGET NAME
TGTEMPLOYEE KEYS (EMPNO) LOAD TYPE 2)
Replication Center Use the Create Q Subscriptions wizard. To open the wizard, expand the appropriate Q Capture or Q Apply schema, right click the Q Subscriptions folder, and select Create.

You can create one Q subscription or many by using the wizard.

Rows and columns page
When you create multiple Q subscriptions at one time, the Replication Center assumes that you want to replicate all columns and rows from each source table. On the Review Q Subscriptions page of the wizard you can modify individual Q subscriptions so that only a subset of the source columns and rows are replicated.
Target tables page
When you create more than one Q subscription at a time, the Target Tables page allows you to review the target object profile. Modify the profile if necessary so that the target tables for the Q subscriptions meet your needs.

The target object profile determines if an existing target table is used or if a new one is created. The Replication Center looks for an object that matches the naming scheme that is defined in the profile, and, if one does not exist, then the object is created.