After the replication environment is up and running, changes that are made to the replication source will be replicated to the target table. You must prune the control tables periodically to prevent them from growing too large. Although the Capture and Apply programs can run continuously, there are times when you will want to stop them (for example, to run utilities that use the table spaces that contain the control tables).
Assume that two new departments were created at the Spiffy Computer Service: a technical writing department and a public relations department.
To update the source table:
DB2 CONNECT TO SAMPLE
DB2 INSERT INTO DEPARTMENT VALUES ('F01','Technical Writing','000110','F01',NULL) DB2 INSERT INTO DEPARTMENT VALUES ('G01','Public Relations','000120','G01',NULL)
DB2 CONNECT TO COPYDB
DB2 SELECT * FROM DEPTCOPY
Table 5 shows the results of the replication, with two new rows
appended to the table.
Table 5. DEPTCOPY table after changes are replicated
DEPTNO | DEPTNAME | MGRNO | ADMRDEPT | LOCATION |
---|---|---|---|---|
A00 | Spiffy Computer Service | 000010 | A00 | - |
B01 | Planning | 000020 | A00 | - |
C01 | Information Center | 000030 | A00 | - |
D01 | Development Center | - | A00 | - |
D21 | Administration Systems | 000070 | D01 | - |
E01 | Support Services | 000050 | A00 | - |
E11 | Operations | 000090 | E01 | - |
E21 | Software Support | 000100 | E01 | - |
F01 | Technical Writing | 000110 | F01 | - |
G01 | Public Relations | 000120 | G01 | - |
The following steps assume that the Capture program is running. If the Capture program is not running, the prune command will not work. Usually pruning should occur during offpeak hours.
To verify that there is something to prune:
DB2 CONNECT TO SAMPLE
DB2 SELECT COUNT(*) FROM ASN.IBMSNAP_UOW
There should be two rows in the unit-of-work table from the previous replication.
To run the prune command:
ASNCMD SAMPLE PRUNE
DB2 SELECT COUNT(*) FROM ASN.IBMSNAP_UOW
There should be no rows in the table.
An important part of maintaining your replication environment is regular database maintenance. Sometimes that maintenance will require you to stop the Capture and Apply programs. For example, you must stop the Capture and Apply programs before you run utilities that directly use the table spaces that are used by these programs.
To stop the Capture program:
ASNCMD SAMPLE STOP
To stop the Apply program:
ASNASTOP DEPTQUAL
You can run DB2 utilities on your database now that you stopped the Capture and Apply programs. (Running the utilities is beyond the scope of this exercise.)