5. Working with a self-added field in a database table
For a table with a self added field that needs to be loaded, that is, the value of the IXF data file in the table, you can add the following parameter to the load command to control the value of the self-added field:
1). Modified by Identityignore: The loaded data file has the value of the self added field, the value of the data file is ignored when load;
2. Modified by identitymissing: There is no self-added field value in the loaded data file, and automatically generates the self Increment field value when load;
3). Modified by Identityoverride: The data file is loaded with a self added field value that uses the value of the self added field in the data file when load.
To make the data in the table containing the field in the target database consistent with the data in the source database, select Use the modified by identityoverride parameter in this article instance to use the value of the field in the data file when importing data. The reader can choose the appropriate control parameters according to different circumstances.
First, find all the table names in the Srcdb1_tables.ddl file that contain the generated ALWAYS as IDENTITY field, and then modified by IdentIT in Srcdb1_load.sql The Yoverride statement fragment is inserted into the load command line for the table that contains the self-added fields.
Listing 8. Self-adding field processing in load script
DB2 load from TEST.IXF of IXF modified by identityoverride inserts into test;
6. Execute Export Script
Performs an export script that exports data from all tables.
# DB2-TVF Srcdb1_export.sql
The exported table data is stored in IXF format under the current path.
7. Save scripts and data files
Copy all DDL scripts and data file *.ixf to the site where the target system resides.
Operations on a LINUX system
1. To create an instance SRCDB1 from the command line processor (CLP):
# DB2ICRT SRCDB1
2. Create database SRCDB1 with the Create DB command, creating the necessary table spaces, and configuring the necessary database parameters.
# DB2 CREATE DATABASE SRCDB1
3. Connect to the database SRCDB1, execute SRCDB1_TABLES.DDL scripts to create buffer pools, tablespaces, UDF, tables, and index,sequence, views and other database objects.
# DB2 Connect to SRCDB1
# DB2-TVF SRCDB1_TABLES.DDL