beautypg.com

IBM Data Server DB2 User Manual

Page 251

background image

Chapter 5. Deploying pre-configured databases

237

Because our tables are empty, we choose the

insert

mode. In Example 5-15 we

show the statements to populate our sample database using the IXF files
exported in the previous section.

Example 5-15 Import statements used to populate our sample database

import from "dept.ixf" of ixf messages "dept.msg" insert into itso.department;
import from "emp.ixf" of ixf messages "emp.msg" insert into itso.employee;
import from "staff.ixf" of ixf messages "staff.msg" insert into itso.staff;

Because referential constraints are set during import, tables must be imported in
the right order. In our example, there is a foreign key relation from the
EMPLOYEE table to the DEPARTMENT table, therefore, we must import the
DEPARTMENT table before the EMPLOYEE table.

There are several other options that can be used to control the import utility. For
a thorough description, refer to the DB2 Infocenter:

http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admi
n.dm.doc/doc/c0004573.html4

Load utility

The load utility writes formatted pages directly into the database, which makes it
much faster then the import utility. The load utility does not perform referential
constraints or table constraint checking. The only validation performed is that the
uniqueness of the indexes. Like the import utility, different load modes are
available to control what to do with the existing data. For an initial load, we can
choose between

insert

or

replace

mode. Because our tables are empty, it makes

no difference which mode is chosen.

After load, the tables with constraints will be in the

integrity pending mode

and

cannot be accessed. You can use the

set integrity

command to check the

constraints and bring the table back to the accessible mode.

In our sample database we have a referential constraint defined between the
EMPLOYEE table to the DEPARTMENT table. After loading, the EMPLOYEE
table will be in the

integrity pending mode

because the foreign key relation has not

been checked. Furthermore, the summary table also has to be checked.
Example 5-16 shows the load statements and the required check statements to
populate our database and make the tables accessible.

Example 5-16 The load and integrity check statements for our sample database

load from "emp.ixf" of ixf messages "emp.msg" insert into itso.employee copy no
indexing mode autoselect;
load from "dept.ixf" OF ixf messages "dept.msg" insert into itso.department
copy no indexing mode autoselect;