EXCHANGE

The EXCHANGE statement switches the content of a base table and its associated clone table.

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared only if DYNAMICRULES run behavior is implicitly or explicitly specified.

Authorization

The privilege set that is defined below must include at least one of the following privileges:

  • The INSERT and DELETE privileges on both the base table and the clone table
  • Ownership of the both the base table and the clone table
  • DBADM authority for the database
  • SYSADM authority
  • Start of changeDATAACCESS authorityEnd of change

Privilege set: If the statement is embedded in an application program, the privilege set is the privileges that are held by the owner of the plan or package. If the statement is dynamically prepared, the privilege set is the union of the privilege sets that are held by each authorization ID of the process.

Syntax

Read syntax diagram
>>-EXCHANGE DATA BETWEEN TABLE--table-name1--AND--table-name2--><

Description

table-name1 and table-name2
Identifies the base table and the associated clone table for which the exchange of data will take place. Either table-name1 or table-name2 can identify the base table. The other table name must identify a clone table that is associated with the specified base table. The name of the base table and the name of the clone table remain unchanged after a data exchange.

Notes

Rules and restrictions: Data exchanges cannot be done for a subset of a table's partitions. There must be a commit between consecutive data exchanges using the EXCHANGE statement.

Examples

Example: Exchange the data of the EMPLOYEE table and its clone table, EMPCLONE.
   EXCHANGE DATA BETWEEN TABLE EMPCLONE AND EMPLOYEE;