0% found this document useful (0 votes)
54 views

DB2 Load

The LOAD utility loads data into one or more tables in a DB2 table space from an input data set. It has several phases including loading records, sorting keys, building indexes, and enforcing constraints. Users must have the proper authorization and can specify options to control logging, constraints, partitioning, statistics collection, and input/output. Examples demonstrate basic loading, partitioning, and using a cursor to define the input rows.

Uploaded by

V J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

DB2 Load

The LOAD utility loads data into one or more tables in a DB2 table space from an input data set. It has several phases including loading records, sorting keys, building indexes, and enforcing constraints. Users must have the proper authorization and can specify options to control logging, constraints, partitioning, statistics collection, and input/output. Examples demonstrate basic loading, partitioning, and using a cursor to define the input rows.

Uploaded by

V J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

LOAD – DB2 utility

LOAD – DB2 utility

Contents
• Purpose
• Authorization
• Input
• Output
• Phases
• Options
• Syntax
• Examples
2
LOAD – DB2 utility

Purpose
• To load one or more tables of a table space

Data Table 1 Table 2 Table n


Data

Table
Tablespace
space

Data
Data
Table 1 Table 2 Table n

Table
Tablespace
space

3
LOAD – DB2 utility

Authorization
• Table Ownership
• LOAD privilege for the database
• DBADM or DBCTRL authority for database
• SYSADM or SYSCTRL authority
• STATS authority on the database to run
LOAD STATISTICS

4
LOAD – DB2 utility

Input
• Data set which contains the data to be
loaded
• Specify its template or DD name with the
INDDN option
• Default name is SYSREC
• It must be a sequential data set that is
readable by BSAM

5
LOAD – DB2 utility

Output
• A loaded table space or partition
• A discard file of rejected records
• An optional summary report of errors
encountered during processing

6
LOAD – DB2 utility

Phases
• UTILINIT – Initialization
• RELOAD – Load records, extract keys
• SORT – Sort extracted keys
• BUILD – Build indexes
• SORTBLD – SORT & BUILD for parallel index
• INDEXVAL – Check unique index constraint
• ENFORCE – Check referential constraint
• DISCARD – Copy error records to discard data set
• REPORT – Generate a summary report
• UTILTERM – Cleanup
7
LOAD – DB2 utility

Options
LOG – indicates whether logging is to occur during the RELOAD phase of the LOAD process.
YES – All records that are loaded are logged. The default is YES.
NO – No logging of data during the load process. It sets the COPY-pending
restriction against the target table space or partition.
NOCOPYPEND – LOAD will not set the table space in the COPY-pending status,
even though LOG NO was specified.

ENFORCE – indicates whether LOAD is to enforce check constraints and referential


constraints.
CONSTRAINTS – constraints are to be enforced. It is default. If LOAD detects a
violation, it deletes the errant row and issues a message to identify it.
NO – constraints are not to be enforced. This option places the target table space in
the CHECK-pending status if at least one referential constraint or check constraint is
defined for the table.

8
LOAD – DB2 utility

Options (cont..)
RESUME – Indicates whether records are to be loaded into an empty or non-empty table
space.
YES – Loads records into a non-empty table space. If the table space is empty, a
warning message is issued, but the table space is loaded.
NO – Loads records into an empty table space. If the table space is not empty, and
you have not used REPLACE, a message is issued and the utility job step terminates
with a job step condition code of 8. The default is NO.

REUSE – Specifies (when used with REPLACE) that LOAD is to logically reset and reuse
DB2-managed data sets without deleting and redefining them. If you do not specify REUSE,
DB2 deletes and redefines DB2-managed data sets to reset them. REUSE must be
accompanied by REPLACE to do the logical reset for all data sets.

9
LOAD – DB2 utility

Options (cont..)
SHRLEVEL – Specifies the extent to which applications can concurrently access the table
space or partition during the LOAD utility job.
NONE – Specifies that applications have no concurrent access to the table space or
partition. The default is NONE.
CHANGE – Specifies that applications can concurrently read from and write to the
table space or partition into which LOAD is loading data. LOAD SHRLEVEL CHANGE
does not perform the SORT, BUILD, SORTBLD, INDEXVAL, ENFORCE, or REPORT
phases .

INDDN ddname – Specifies the DD statement or template that identifies the input data set
for the partition. The default is SYSREC.

INCURSOR cursor-name – Specifies the cursor for the input data set. You must declare the
cursor before it is used by the LOAD utility. Use the EXEC SQL utility control statement to
define the cursor. You cannot load data into the same table on which you defined the
cursor.

10
LOAD – DB2 utility

Options (cont..)
REPLACE – Indicates whether the table space and all its indexes need to be reset to empty
before records are loaded. With this option, the newly loaded rows replace all existing
rows of all tables in the table space, not just those of the table that you are loading.

STATISTICS – Specifies the gathering of statistics for a table space, index, or both; the
statistics are stored in the DB2 catalog.

REPORT – Indicates whether a set of messages is to be generated to report the collected


statistics.
NO - Indicates that the set of messages is not sent to SYSPRINT as output.
YES - Indicates that the set of messages is sent to SYSPRINT as output. REPORT YES
always generates a report of SPACE and ACCESSPATH statistics.

11
LOAD – DB2 utility

Options (cont..)
UPDATE – whether the collected statistics are to be inserted into the catalog tables.
ALL - all collected statistics are to be updated in the catalog. Its default.
ACCESSPATH - Indicates that updates are to be made only to the catalog table
columns that provide statistics that are used for access path selection.
SPACE - updates are to be made only to the catalog table columns that provide
space related statistics of a particular table space or index.
NONE - no catalog tables are to be updated with the collected statistics
HISTORY – records all catalog table updates to the catalog history tables.
ALL - all collected statistics are to be updated in the catalog history tables.
ACCESSPATH - Indicates that updates are to be made only to the catalog history
table columns that provide statistics that are used for access path selection.
SPACE - updates are to be made only to the catalog history table columns that
provide space related statistics of a particular table space or index.
NONE - no catalog history tables are to be updated with the collected statistics.
12
LOAD – DB2 utility

Options (cont..)
COPYDDN (ddname1,ddname2) – Specifies the DD statements for the primary (ddname1) and
backup (ddname2) copy data sets for the image copy. The default is SYSCOPY for the
primary copy. No default exists for the backup copy. The COPYDDN keyword can be
specified only with REPLACE. The table space or partition for which an image copy is
produced is not placed in COPY-pending status.
RECOVERYDDN (ddname3,ddname4) – Specifies the DD statements for the primary
(ddname3) and backup (ddname4) copy data sets for the image copy at the recovery site.

ERRDDN ddname – Specifies the DD statement for a work data set that is being used during
error processing. Information about errors that are encountered during processing is stored
in this data set. A SYSERR data set is required if you request discard processing. The
default is SYSERR.
DISCARDDN ddname – Specifies the DD statement for a discard data set that is to hold
copies of records that are not loaded (for example, if they contain conversion errors). The
discard data set also holds copies of records that are loaded and then removed (due to
unique index errors, or referential or check constraint violations).

13
LOAD – DB2 utility

Syntax

14
LOAD – DB2 utility

Examples
1)

Load the records from the data set that is defined by SYSREC (default) into the table DSN8810.DEPT.
POSITION (start:length) clause specifies the location of a field in the input record. DEPTNO,
DEPTNAME, MGRNO etc. are the columns of the table DEPT. RESUME YES specifies new records are
added at the end of the table.

15
LOAD – DB2 utility

Examples (cont..)
2)

Data from the data set that is defined by SYSREC DD statement is to be loaded into the first partition
of table DSN8810.DEPT. The REPLACE option indicates that the input data is to replace only the
specified partition. If the REPLACE option was specified before the PART option, REPLACE would
indicate that entire table space is to be replaced, and the data is to be loaded into the specified
partition.

16
LOAD – DB2 utility

Examples (cont..)
3)

All rows that are identified by cursor C1 are to be loaded into table MYEMP. The INCURSOR option is
used to specify cursor C1, which is defined in the EXEC SQL utility control statement. Cursor C1 points
to the rows that are returned by executing the statement SELECT * FROM DSN8810.EMP. In this
example, the column names in table DSN8810.EMP are the same as the column names in table MYEMP.
Note that the cursor cannot be defined on the same table into which DB2 is to load the data.

17
LOAD – DB2 utility

Reference Manual
For more information on utilities, search “DB2 Utility Guide and Reference,
SC18-7427” on IBM website – www.ibm.com

18
Questions
?

Company Confidential
Thank You!

Company Confidential

You might also like