Exchanging data between a base table and clone table

You can exchange table data and index data between the base table and clone table by using the EXCHANGE statement.

Procedure

Begin general-use programming interface information. To exchange data between the base table and clone table, complete the following steps:

  1. Issue an EXCHANGE statement with the DATA BETWEEN TABLE table-name1 AND table-name2 syntax.
    EXCHANGE DATA BETWEEN TABLE table-name1 AND table-name2
  2. Issue a COMMIT statement.
    An error might be returned if you access the tables or issue another EXCHANGE statement before issuing a COMMIT statement.

Results

After a data exchange, the base and clone table names remain the same as they were prior to the data exchange. No data movement actually takes place. The instance numbers in the underlying VSAM data set names for the objects (tables and indexes) in a clone relationship toggle in the range 1–2. For example, suppose that a base table exists with the data set name *I0001.*. When the table is cloned, the clone's data set is initially named *.I0002.*. After an exchange, the base objects are named *.I0002.* and the clones are named *I0001.*. Each time that an exchange happens, the instance numbers that represent the base and the clone objects change.

End general-use programming interface information.

What to do next

Start of changeExchanging data between the base table and the clone table does not invalidate packages. However, Db2 writes VALID='A' in the SYSIBM.SYSPACKAGE catalog table rows for packages that reference the tables to indicate that a rebind might be needed before the package can use the exchanged data.End of change