Adding existing columns to a Q subscription (bidirectional or peer-to-peer replication)
You can add existing columns from the source table to a bidirectional or peer-to-peer Q subscription while the replication programs are running. If the columns are not existing and your servers are at Version 10.1 or later, you use a different procedure.
Before you begin
Before you begin
- The Q subscriptions that specify the table must be in A (active) state at all servers.
- Linux®, UNIX, and Windows: If the data type of the column is LONG VARCHAR or GRAPHIC, the source database or subsystem must be configured with DATA CAPTURE CHANGES INCLUDE VARCHAR COLUMNS.
About this task
Restrictions
- For pre-V12 Db2 for z/OS: If you add a column with a
non-system default, for example
ALTER TABLE OEUSR01.SRC_TABLE ADD COLUMN N01 CHAR(1) NOT NULL WITH DEFAULT 'Y'
, and then update that column with the system default value, the column does not replicate until you perform a REORG on the source table space. All other values replicate. For more information about the need for REORG, see When replication requires table space REORG after ALTER TABLE (z/OS). - You cannot alter the default value of a newly added column until the ADDCOL signal for that column is processed.
- If you are adding more than 20 columns, you must issue a Db2 COMMIT statement after 20 ALTER ADD COLUMN operations at the source table or after inserting 20 ADDCOL signals. To avoid previous issues with ALTER ADD operations that exceed 20 columns, apply APAR PI88530.
- The target cannot be a stored procedure.
About this task
To use this procedure, first you alter a table at one server to add a column. Then you insert an SQL signal at the server. When the signal is processed, the versions of the table at the other servers are automatically altered to add the column, unless you added it manually. The signal also adds the column to the Q subscription definitions at all servers.
You can add any number of columns to the source table at a time. You can do this while the Q Capture and Q Apply programs are running or stopped.
Procedure
To add columns to replicate in bidirectional or peer-to-peer replication:
Procedure
Example
Consider the following example. A peer-to-peer configuration has three servers: ServerA, ServerB, and ServerC, and six Q subscriptions: subA2B, subB2A, subA2C, subC2A, subB2C, and subC2B for the EMPLOYEE table.
You add a column, ADDRESS, to the EMPLOYEE table on ServerA.
Then you insert an ADDCOL signal for the Q subscription that handles
transactions from ServerA to ServerB, and specify subA2B;ADDRESS
for
the Q subscription name and column name. Only one ADDCOL signal is
required. The replication programs automatically add the ADDRESS column
to the EMPLOYEE tables at ServerB and ServerC, and add the column
definition to all six Q subscriptions.