Load (load)
The load command format is similar to the import, the command keyword is load, but the following arguments are much more than the import command, and the detailed usage can refer to the DB2 documentation.
Loading is similar to importing the data in the input file into the target table, and the differences between the two will be explained Step-by-step in the instance.
The target table must already exist before loading.
The load performance is higher than the import, and the reason is explained in detail in the following example.
The mount operation is not logged to the log, so the log file cannot be used for roll forward operations.
Loading is divided into 4 stages:
1. Loading stage
Two things happen at this stage: The data is stored in the table, the index keys are collected and sorted. When loaded, the DBA can specify how long to generate a consensus point.
It is the checkpoint of the Mount tool. If the mount is interrupted during execution, it can proceed from the last point of convergence to resume execution.
2. Construction phase
During the build phase, indexes are created based on the index key information collected during the Mount phase. If an error occurs during the build phase, the Mount tool restarts, and it starts over at the start of the build phase.
3. In the deletion phase, all rows that violate a unique or PRIMARY KEY constraint are deleted and copied to an exception table if the appropriate option is specified in the statement. When the input row is rejected, a message is generated in the message file.
4. Index copy phase
If the system temporary table space is specified for index creation during a mount operation, and the READ ACCESS option is selected, the index data is copied from the System temporary table space to the original tablespace.
All four phases of the loading process are part of the operation, and the mount operation is completed only after all four phases have been completed. Messages are generated at each stage, and once an error occurs in one of these phases, these messages can help the DBA analyze and resolve the problem.
The import operation checks to see if the constraint is met and is logged in the log file each time a row of data is inserted.
Below we look at some of the load command-specific features, the import command can do is no longer detailed.
Example 12: Loading from the cursor type file
Define a cursor
Declare mycur cursor FOR SELECT * FROM org
Create a new table with a structure compatible with cursor
CREATE TABLE org2 like org
Mount from cursor
Load from Mycur of cursor inserts into ORG2
In addition to being mounted from cursor, you can also mount from files, pipes, and devices. The import command can only be imported from a file.