Command Reference
Loads data from files, tapes, or named pipes into a DB2 table. Tape
is not supported on OS/2. The load utility does not support
loading data at the hierarchy level.
Scope
This command affects only the partition to which a direct connection
exists; the load utility operates on a single database partition only.
Authorization
One of the following:
- sysadm
- dbadm
- load authority on the database and
- INSERT privilege on the table when the load utility is invoked in APPEND,
TERMINATE, or RESTART mode
- INSERT and DELETE privilege on the table when the load utility is invoked
in REPLACE mode.
Note: | Since all load processes (and all DB2 server processes, in general), are
owned by the instance owner, and all of these processes use the identification
of the instance owner to access needed files, the instance owner must have
read access to input data files. These input data files must be
readable by the instance owner, regardless of who invokes the command.
|
Required Connection
Database. If implicit connect is enabled, a connection to the
default database is established.
Instance. An explicit attachment is not required. If a
connection to the database has been established, an implicit attachment to the
local instance is attempted.
Command Syntax
.-,-------------.
V |
>>-LOAD FROM------+-filename-+--+--OF--filetype----------------->
+-pipename-+
'-device---'
>-----+-----------------------------+--------------------------->
| .-,-----------. |
| V | |
'-LOBS FROM-----lob-path---+--'
>-----+-----------------------------------+--------------------->
| .-----------------. |
| V | |
'-MODIFIED BY-----filetype-mod---+--'
>-----+-----------------------------------------------------------------------------------------------+>
| .-,---------------------------. |
| V | |
'-METHOD--+-L--(-----column-start--column-end---+---)--+-----------------------------------+-+--'
| | .-,----. | |
| | V | | |
| '-NULL INDICATORS--(-----n---+---)--' |
| .-,--------------. |
| V | |
+-N--(-----column-name---+---)-----------------------------------------------------+
| .-,------------------. |
| V | |
'-P--(-----column-position---+---)-------------------------------------------------'
>-----+---------------+---+--------------+---------------------->
'-SAVECOUNT--n--' '-ROWCOUNT--n--'
>-----+------------------+---+-------------------------+-------->
'-WARNINGCOUNT--n--' '-MESSAGES--message-file--'
>-----+--------------------------------+---+-INSERT----+-------->
'-TEMPFILES PATH--temp-pathname--' +-REPLACE---+
+-RESTART---+
'-TERMINATE-'
>----INTO--table-name----+------------------------------+------->
| .-,----------------. |
| V | |
'-(-----insert-column---+---)--'
>-----+--------------------------------------------+------------>
'-DATALINK SPECIFICATION--| datalink-spec |--'
>-----+----------------------------+---------------------------->
'-FOR EXCEPTION--table-name--'
>-----+-------------------------------------------------------------------------------------------+>
| .-YES-. |
'-STATISTICS--+-+-----+--+-+---------------------------------------------------------+-+-+--'
| | '-WITH DISTRIBUTION--+---------------------------------+--' | |
| | '-AND--+----------+--INDEXES ALL--' | |
| | '-DETAILED-' | |
| '-+---------------------------------------+-------------------' |
| '--+-AND-+---+----------+--INDEXES ALL--' |
| '-FOR-' '-DETAILED-' |
'-NO-----------------------------------------------------------------------'
>-----+------------------------------------------------------------------+>
| .-NO-----------------------------------------------------. |
+-COPY--+-YES--+-USE ADSM--+---------------------------+-------+-+-+
| | '-OPEN--num-sess--SESSIONS--' | |
| | .-,-------------------. | |
| | V | | |
| +-TO-----device/directory---+-------------------+ |
| '-LOAD--lib-name--+---------------------------+-' |
| '-OPEN--num-sess--SESSIONS--' |
'-NONRECOVERABLE---------------------------------------------------'
>-----+---------------+---+--------------------+---------------->
'-HOLD QUIESCE--' '-WITHOUT PROMPTING--'
>-----+---------------------------+---+---------------------+--->
'-DATA BUFFER--buffer-size--' '-CPU_PARALLELISM--n--'
>-----+----------------------+---------------------------------->
'-DISK_PARALLELISM--n--'
>-----+---------------------------------+----------------------><
'-INDEXING MODE--+-AUTOSELECT--+--'
+-REBUILD-----+
+-INCREMENTAL-+
'-DEFERRED----'
datalink-spec
.-,--------------------------------------------------------------------------------------------------.
V |
|------(--+-----------------+--+----------------------------------+---+--------------------------+---)---+->
'-DL_LINKTYPE URL-' +-DL_URL_REPLACE_PREFIX--"prefix"--+ '-DL_URL_SUFFIX--"suffix"--'
'-DL_URL_DEFAULT_PREFIX--"prefix"--'
>---------------------------------------------------------------|
Command Parameters
- COPY NO
- Specifies that the table space in which the table resides will be placed
in backup pending state if forward recovery is enabled (that is,
logretain or userexit is on). The data will not
be accessible until a table space backup or a full database backup is
made.
- COPY YES
- Specifies that a copy of the loaded data will be saved. This option
is invalid if forward recovery is disabled (both logretain and
userexit are off). The option is not supported for tables with
DATALINK columns.
- USE ADSM
- Specifies that the copy will be stored using ADSTAR Distributed Storage
Manager (ADSM).
- OPEN num-sess SESSIONS
- The number of I/O sessions to be used with ADSM or the vendor
product. The default value is 1.
- TO device/directory
- Specifies the device or directory on which the copy image will be
created. Tape is not supported on OS/2; copy to tapes is not
supported for DB2 servers running on SCO UnixWare 7.
- LOAD lib-name
- The name of the shared library (DLL on OS/2 or the Windows operating
system) containing the vendor backup and restore I/O functions to be
used. It may contain the full path. If the full path is not
given, it will default to the path where the user exit programs reside.
- CPU_PARALLELISM n
- Specifies the number of processes or threads that the load utility will
spawn for parsing, converting, and formatting records when building table
objects. This parameter is designed to exploit intra-partition
parallelism. It is particularly useful when loading presorted data,
because record order in the source data is preserved. If the value of
this parameter is zero, or has not been specified, the load utility uses an
intelligent default value at run time.
Notes:
- If this parameter is used with tables containing either LOB or LONG
VARCHAR fields, its value becomes one, regardless of the number of system CPUs
or the value specified by the user.
- Specifying a small value for the SAVECOUNT parameter causes the loader to
perform many more I/O operations to flush both data and table metadata.
When CPU_PARALLELISM is greater than one, the flushing operations are
asynchronous, permitting the loader to exploit the CPU. When
CPU_PARALLELISM is set to one, the loader waits on I/O during consistency
points. A load operation with CPU_PARALLELISM set to two, and
SAVECOUNT set to 10 000, completes faster than the same operation
with CPU_PARALLELISM set to one, even though there is only one CPU.
- DATA BUFFER buffer-size
- Specifies the number of 4KB pages (regardless of the degree of
parallelism) to use as buffered space for transferring data within the
utility. If the value specified is less than the algorithmic minimum,
the minimum required resource is used, and no warning is returned.
This memory is allocated directly from the utility heap, whose size can be
modified through the util_heap_sz database configuration
parameter.
If a value is not specified, an intelligent default is calculated by the
utility at run time. The default is based on a percentage of the free
space available in the utility heap at the instantiation time of the loader,
as well as some characteristics of the table.
- DATALINK SPECIFICATION
- For each DATALINK column, there can be one column specification enclosed
by parentheses. Each column specification consists of one or more
DL_LINKTYPE, prefix, and a DL_URL_SUFFIX specification. The
prefix specification can be either DL_URL_REPLACE_PREFIX or
DL_URL_DEFAULT_PREFIX.
There can be as many DATALINK column specifications as the number of
DATALINK columns defined in the table. The order of specifications
follows the order of DATALINK columns found within the insert-column
list, or within the table definition (if an insert-column list is not
specified).
- DISK_PARALLELISM n
- Specifies the number of processes or threads that the load utility will
spawn for writing data to the table space containers. If a value is not
specified, the utility selects an intelligent default based on the number of
table space containers and the characteristics of the table.
- DL_LINKTYPE
- If specified, it should match the LINKTYPE of the column
definition. Thus, DL_LINKTYPE URL is acceptable if the column
definition specifies LINKTYPE URL.
- DL_URL_DEFAULT_PREFIX "prefix"
- If specified, it should act as the default prefix for all DATALINK values
within the same column. In this context, prefix refers to the "scheme
host port" part of the URL specification.
Examples of prefix are:
"http://server"
"file://server"
"file:"
"http://server:80"
If no prefix is found in the column data, and a default prefix is
specified with DL_URL_DEFAULT_PREFIX, the default prefix is prefixed
to the column value (if not NULL).
For example, if DL_URL_DEFAULT_PREFIX specifies the default prefix
"http://toronto":
- The column input value "/x/y/z" is stored as
"http://toronto/x/y/z".
- The column input value "http://coyote/a/b/c" is stored as
"http://coyote/a/b/c".
- The column input value NULL is stored as NULL.
- DL_URL_REPLACE_PREFIX "prefix"
- This clause is useful when loading or importing data previously generated
by the export utility, if the user wants to globally replace the host name in
the data with another host name. If specified, it becomes the prefix
for all non-NULL column values. If a column value has a
prefix, this will replace it. If a column value has no prefix, the
prefix specified by DL_URL_REPLACE_PREFIX is prefixed to the column
value.
For example, if DL_URL_REPLACE_PREFIX specifies the prefix
"http://toronto":
- The column input value "/x/y/z" is stored as
"http://toronto/x/y/z".
- The column input value "http://coyote/a/b/c" is stored as
"http://toronto/a/b/c". Note that "toronto" replaces
"coyote".
- The column input value NULL is stored as NULL.
- DL_URL_SUFFIX "suffix"
- If specified, it is appended to every non-NULL column value for the
column. It is, in fact, appended to the "path" component of the data
location part of the DATALINK value.
- FOR EXCEPTION table-name
- Specifies the exception table into which rows in error will be
copied. Any row that is in violation of a unique index or a primary key
index is copied. DATALINK exceptions are also captured in the exception
table.
Information that is written to the exception table is not
written to the dump file (for a description of the dumpfile
modifier, see Table 7). In a partitioned database environment, an exception
table must be defined for those nodes on which the loading table is
defined. The dump file, on the other hand, contains rows that cannot be
loaded because they are invalid or have syntax errors. For more
information, see the Data Movement Utilities Guide and Reference.
- FROM filename/pipename/device
- Specifies the file, pipe, or device that contains the data being
loaded. This file, pipe, or device must reside on the node where the
database resides. If several names are specified, they will be
processed in sequence. If the last item specified is a tape device, the
user is prompted for another tape. Valid response options are:
- c
- Continue. Continue using the device that generated the warning
message (for example, when a new tape has been mounted).
- d
- Device terminate. Stop using the device that generated the warning
message (for example, when there are no more tapes).
- t
- Terminate. Terminate all devices.
Notes:
- Tape is not supported on OS/2.
- It is recommended that the fully qualified file name be used. If
the server is remote, the fully qualified file name must be used. If
the database resides on the same node as the caller, relative paths may be
used.
- Loading data from multiple IXF files is supported if the files are
physically separate, but logically one file. It is not
supported if the files are both logically and physically separate.
- If, when specifying pipename on OS/2, less than the
expected amount of data is loaded, clean up system resources (IPL is
recommended), and reissue the LOAD command.
- HOLD QUIESCE
- Specifies that the utility should leave the table in quiesced exclusive
state after the load operation. To unquiesce the table spaces,
issue:
db2 quiesce tablespaces for table <tablename> reset
- INDEXING MODE
- Specifies whether the load utility is to rebuild indexes or to extend them
incrementally. Valid values are:
- AUTOSELECT
- The load utility will automatically decide between REBUILD or INCREMENTAL
mode.
- REBUILD
- All indexes will be rebuilt. The utility must have sufficient
resources to sort all index key parts for both old and appended table
data.
- INCREMENTAL
- Indexes will be extended with new data. This approach consumes
index free space. It only requires enough sort space to append index
keys for the inserted records. This method is only supported in cases
where the index object is valid and accessible at the start of a load
operation (it is, for example, not valid immediately following a load
operation in which the DEFERRED mode was specified). If this mode is
specified, but not supported due to the state of the index, a warning is
returned, and the load operation continues in REBUILD mode. Similarly,
if a load restart operation is begun in the load build phase, INCREMENTAL mode
is not supported.
Incremental indexing is not supported when all of the following conditions
is true:
- The LOAD COPY option is specified (logretain or userexit
is enabled).
- The table resides in a DMS table space.
- The index object resides in a table space that is shared by other table
objects belonging to the table being loaded.
To bypass this restriction, it is recommended that indexes be placed in a
separate table space.
- DEFERRED
- The load utility will not attempt index creation if this mode is
specified. Indexes will be marked as needing a refresh. The
first access to such indexes that is unrelated to a load operation may force a
rebuild (for more information, see the Administration
Guide), or indexes may be rebuilt when the database is restarted. This
approach requires enough sort space for all key parts for the largest
index. The total time subsequently taken for index construction is
longer than that required in REBUILD mode. Therefore, when performing
multiple load operations with deferred indexing, it is advisable (from a
performance viewpoint) to let the last load operation in the sequence perform
an index rebuild, rather than allow indexes to be rebuilt at first non-load
access.
Deferred indexing is only supported for tables with non-unique indexes, so
that duplicate keys inserted during the load phase are not persistent after
the load operation.
- INSERT
- One of four modes under which the load utility can execute. Adds
the loaded data to the table without changing the existing table data.
- insert-column
- Specifies the table column into which the data is to be inserted.
The load utility cannot parse columns whose names contain one or more
spaces. For example,
db2 load from delfile1 of del modified by noeofchar noheader
method P (1, 2, 3, 4, 5, 6, 7, 8, 9)
insert into table1 (BLOB1, S2, I3, Int 4, I5, I6, DT7, I8, TM9)
will fail because of the Int 4 column. The solution is to
enclose such column names with double quotation marks:
db2 load from delfile1 of del modified by noeofchar noheader
method P (1, 2, 3, 4, 5, 6, 7, 8, 9)
insert into table1 (BLOB1, S2, I3, "Int 4", I5, I6, DT7, I8, TM9)
- INTO table-name
- Specifies the database table into which the data is to be loaded.
This table cannot be a system table. An alias, or the fully qualified
or unqualified table name can be specified. A qualified table name is
in the form schema.tablename. If an unqualified table
name is specified, the table will be qualified with the current authorization
ID.
- LOBS FROM lob-path
- The path to the data files containing LOB values to be loaded. The
path must end with a slash (/). The names of the LOB data files
are stored in the main data file (ASC, DEL, or IXF), in the column that will
be loaded into the LOB column. This option is ignored if
lobsinfile is not specified within the filetype-mod
string (see Table 7).
- MESSAGES message-file
- Specifies the destination for warning and error messages that occur during
the load operation. If a message file is not specified, messages are
written to standard output. If the complete path to the file is not
specified, the load utility uses the current directory and the default drive
as the destination. If the name of a file that already exists is
specified, the utility appends the information.
- METHOD
-
- L
- Specifies the start and end column numbers from which to load data.
Note: | This method can only be used with ASC files, and is the only valid option for
that file type.
|
- N
- Specifies the names of the columns in the data file to be loaded.
The case of these column names must match the case of the corresponding names
in the system catalogs. Each column in the table that is not nullable
should be included in this list. Specify only complete subsets of
column names (for example, given file columns F1, F2, F3, F4, F5, and F6, and
table columns C1 INT, C2 INT NOT NULL, C3 INT NOT NULL, and C4 INT,
method N (F1,F2,F3,F4) insert into table_name (C1,C2,C3,C4) is a
valid request, while method N (F1,F4) is not valid, since there
will be no data to put into C3.
Note: | This method can only be used with IXF files.
|
- P
- Specifies the numbers of the columns to be loaded. Each column in
the table that is not nullable should be included in this list. Specify
only complete subsets of column numbers (for example, given file columns F1,
F2, F3, F4, F5, and F6, and table columns C1 INT, C2 INT NOT NULL, C3 INT NOT
NULL, and C4 INT, method P (1,2,3,4) is a valid request, while
method P (1,4) is not valid.
Note: | This method can only be used with IXF or DEL files, and is the only valid
option for the DEL file type.
|
- MODIFIED BY filetype-mod
- Specifies additional options (see Table 7).
- NONRECOVERABLE
- Specifies that the load transaction is to be marked as non-recoverable,
and that it will not be possible to recover it by a subsequent roll forward
action. The rollforward utility will skip the transaction, and will
mark the table into which data was being loaded as "invalid".
The utility will also ignore any subsequent transactions against that
table. After the roll forward is completed, such a table can only be
dropped.
With this option, table spaces are not put in backup pending state
following the load operation, and a copy of the loaded data does not have to
be made during the load operation.
This option should not be used when DATALINK columns with the FILE LINK
CONTROL attribute are present in, or being added to, the table.
- NULL INDICATORS n
- Specifies a column (by number) to be used as a NULL indicator
field. If this option is used, a NULL indicator column for each data
column must also be specified. A value of zero indicates that the data
column is not nullable, and that there will always be data in that
column.
A value of Y in the NULL indicator column specifies that the
column data is NULL. Any character other than Y
in the NULL indicator column specifies that the column data is not NULL, and
that column data specified by the METHOD L option will be loaded.
The NULL indicator character can be changed using the MODIFIED BY option
(see the description of the nullindchar modifier in Table 7).
- OF filetype
- Specifies the format of the data in the input file:
- ASC (non-delimited ASCII format)
- DEL (delimited ASCII format)
- IXF (integrated exchange format, PC version), exported from the same or
from another DB2 table.
For more information about file formats, see the "Export/Import/Load
Utility File Formats" appendix in the Data Movement Utilities Guide and Reference.
- REPLACE
- One of four modes under which the load utility can execute. Deletes
all existing data from the table, and inserts the loaded data. The
table definition and index definitions are not changed. If this option
is used when moving data between hierarchies, only the data for an entire
hierarchy, not individual subtables, can be replaced.
This option is not supported for tables with DATALINK columns.
- RESTART
- One of four modes under which the load utility can execute.
Restarts a previously interrupted load operation. The load operation
will automatically continue from the last consistency point in the load,
build, or delete phase.
- RESTARTCOUNT
- Reserved.
- ROWCOUNT n
- Specifies the number of n physical records in the file to be
loaded. Allows a user to load only the first n rows in a
file.
- SAVECOUNT n
- Specifies that the load utility is to establish consistency points after
every n rows. This value is converted to a page count, and
rounded up to intervals of the extent size. Since a message is issued
at each consistency point, this option should be selected if the load
operation will be monitored using LOAD QUERY. If the value of n is not sufficiently
high, the synchronization of activities performed at each consistency point
will impact performance.
The default value is zero, meaning that no consistency points will be
established, unless necessary.
- SORT BUFFER buffer-size
- Reserved.
- STATISTICS NO
- Specifies that no statistics are to be collected, and that the statistics
in the catalogs are not to be altered. This is the default.
- STATISTICS YES
- Specifies that statistics are to be collected for the table and for any
existing indexes. This option is supported only if the load operation
is in REPLACE mode.
- WITH DISTRIBUTION
- Specifies that distribution statistics are to be collected.
- AND INDEXES ALL
- Specifies that both table and index statistics are to be collected.
- FOR INDEXES ALL
- Specifies that only index statistics are to be collected.
- DETAILED
- Specifies that extended index statistics are to be collected.
- TEMPFILES PATH temp-pathname
- Specifies the name of the path to be used when creating temporary files
during a load operation, and should be fully qualified according to the server
node.
Temporary files take up file system space. Sometimes, this space
requirement is quite substantial. Following is an estimate of how much
file system space should be allocated for all temporary files:
- 4 bytes for each duplicate or rejected row containing DATALINK values
- 136 bytes for each message that the load utility generates
- 15KB overhead if the data file contains long field data or LOBs.
This quantity can grow significantly if the INSERT option is specified, and
there is a large amount of long field or LOB data already in the table.
For more information about temporary files, see the Data Movement Utilities Guide and Reference.
- TERMINATE
- One of four modes under which the load utility can execute.
Terminates a previously interrupted load operation, and rolls back the
operation to the point in time at which it started, even if consistency points
were passed. The states of any table spaces involved in the operation
return to normal, and all table objects are made consistent (index objects may
be marked as invalid, in which case index rebuild will automatically take
place at next access). If the load operation being terminated is a load
REPLACE, the table will be truncated to an empty table after the load
TERMINATE operation. If the load operation being terminated is a load
INSERT, the table will retain all of its original records after the load
TERMINATE operation.
If the table spaces in which the table resides are not in load pending
state, this option does not affect the state of the table spaces.
The load terminate option will not remove a backup pending state from table
spaces.
- USING directory
- Reserved.
- WARNINGCOUNT n
- Stops the load operation after n warnings. Set this
parameter if no warnings are expected, but verification that the correct file
and table are being used is desired. If n is zero, or this
option is not specified, the load operation will continue regardless of the
number of warnings issued. If the load operation is stopped because the
threshold of warnings was encountered, another load operation can be started
in RESTART mode. The load operation will automatically continue from
the last consistency point. Alternatively, another load operation can
be initiated in REPLACE mode, starting at the beginning of the input
file.
- WITHOUT PROMPTING
- Specifies that the list of data files contains all the files that are to
be loaded, and that the devices or directories listed are sufficient for the
entire load operation. If a continuation input file is not found, or
the copy targets are filled before the load operation finishes, the load
operation will fail, and the table will remain in load pending state.
If this option is not specified, and the tape device encounters an end of
tape for the copy image, or the last item listed is a tape device, the user is
prompted for a new tape on that device. Tape is not supported on
OS/2.
Examples
Example 1
TABLE1 has 5 columns:
- COL1 VARCHAR 20 NOT NULL WITH DEFAULT
- COL2 SMALLINT
- COL3 CHAR 4
- COL4 CHAR 2 NOT NULL WITH DEFAULT
- COL5 CHAR 2 NOT NULL
ASCFILE1 has 6 elements:
- ELE1 positions 01 to 20
- ELE2 positions 21 to 22
- ELE5 positions 23 to 23
- ELE3 positions 24 to 27
- ELE4 positions 28 to 31
- ELE6 positions 32 to 32
- ELE6 positions 33 to 40
Data Records:
1...5....10...15...20...25...30...35...40
Test data 1 XXN 123abcdN
Test data 2 and 3 QQY wxyzN
Test data 4,5 and 6 WWN6789 Y
The following command loads the table from the file:
db2 load from ascfile1 of asc modified by striptblanks reclen=40
method L (1 20, 21 22, 24 27, 28 31)
null indicators (0,0,23,32)
insert into table1 (col1, col5, col2, col3)
Notes:
- The specification of striptblanks in the MODIFIED BY parameter
forces the truncation of blanks in VARCHAR columns (COL1, for example, which
is 11, 17 and 19 bytes long, in rows 1, 2 and 3, respectively).
- The specification of reclen=40 in the MODIFIED BY parameter
indicates that there is no new-line character at the end of each input record,
and that each record is 40 bytes long. The last 8 bytes are not used to
load the table.
- Since COL4 is not provided in the input file, it will be inserted into
TABLE1 with its default value (it is defined NOT NULL WITH DEFAULT).
- Positions 23 and 32 are used to indicate whether COL2 and COL3 of TABLE1
will be loaded NULL for a given row. If there is a Y in the
column's null indicator position for a given record, the column will be
NULL. If there is an N, the data values in the column's
data positions of the input record (as defined in
L(........)) are used
as the source of column data for the row. In this example, neither
column in row 1 is NULL; COL2 in row 2 is NULL; and COL3 in row 3 is
NULL.
- In this example, the NULL INDICATORS for COL1 and COL5 are specified as 0
(zero), indicating that the data is not nullable.
- The NULL INDICATOR for a given column can be anywhere in the input record,
but the position must be specified, and the Y or N
values must be supplied.
Example 2 (Loading LOBs from Files)
TABLE1 has 3 columns:
- COL1 CHAR 4 NOT NULL WITH DEFAULT
- LOB1 LOB
- LOB2 LOB
ASCFILE1 has 3 elements:
- ELE1 positions 01 to 04
- ELE2 positions 06 to 13
- ELE3 positions 15 to 22
The following files reside in either /u/user1 or
/u/user1/bin:
- ASCFILE2 has LOB data
- ASCFILE3 has LOB data
- ASCFILE4 has LOB data
- ASCFILE5 has LOB data
- ASCFILE6 has LOB data
- ASCFILE7 has LOB data
Data Records in ASCFILE1:
1...5....10...15...20...25...30.
REC1 ASCFILE2 ASCFILE3
REC2 ASCFILE4 ASCFILE5
REC3 ASCFILE6 ASCFILE7
The following command loads the table from the file:
db2 load from ascfile1 of asc
lobs from /u/user1, /u/user1/bin
modified by lobsinfile reclen=22
method L (1 4, 6 13, 15 22)
insert into table1
Notes:
- The specification of lobsinfile in the MODIFIED BY parameter
tells the loader that all LOB data is to be loaded from files.
- The specification of reclen=22 in the MODIFIED BY parameter
indicates that there is no new-line character at the end of each input record,
and that each record is 22 bytes long.
- LOB data is contained in 6 files, ASCFILE2 through ASCFILE7. Each
file contains the data that will be used to load a LOB column for a specific
row. The relationship between LOBs and other data is specified in
ASCFILE1. The first record of this file tells the loader to place REC1
in COL1 of row 1. The contents of ASCFILE2 will be used to load LOB1 of
row 1, and the contents of ASCFILE3 will be used to load LOB2 of row 1.
Similarly, ASCFILE4 and ASCFILE5 will be used to load LOB1 and LOB2 of row 2,
and ASCFILE6 and ASCFILE7 will be used to load the LOBs of row 3.
- The LOBS FROM parameter contains 2 paths that will be searched for the
named LOB files when those files are required by the loader.
- To load LOBs directly from ASCFILE1 (a non-delimited ASCII file), without
the lobsinfile modifier, the following rules must be
observed:
- The total length of any record, including LOBs, cannot exceed 32KB.
- LOB fields in the input records must be of fixed length, and LOB data
padded with blanks as necessary.
- The striptblanks modifier must be specified, so that the
trailing blanks used to pad LOBs can be removed as the LOBs are inserted into
the database.
Example 3 (Using Dump Files)
Table FRIENDS is defined as:
table friends "( c1 INT NOT NULL, c2 INT, c3 CHAR(8) )"
If an attempt is made to load the following data records into this table,
23, 24, bobby
, 45, john
4,, mary
the second row is rejected because the first INT is NULL, and the column
definition specifies NOT NULL. Columns which contain initial characters
that are not consistent with the DEL format will generate an error, and the
record will be rejected. Such records can be written to a dump file
(see Table 7).
DEL data appearing in a column outside of character delimiters is ignored,
but does generate a warning. For example:
22,34,"bob"
24,55,"sam" sdf
The utility will load "sam" in the third column of the table, and the
characters "sdf" will be flagged in a warning. The record is not
rejected. Another example:
22 3, 34,"bob"
The utility will load 22,34,"bob", and generate a warning that
some data in column one following the 22 was ignored. The
record is not rejected.
Example 4 (Loading DATALINK Data)
The following command loads the table MOVIETABLE from the input file
delfile1, which has data in the DEL format:
db2 load from delfile1 of del
modified by dldel|
insert into movietable (actorname, description, url_making_of, url_movie)
datalink specification (dl_url_default_prefix "http://narang"),
(dl_url_replace_prefix "http://bomdel" dl_url_suffix ".mpeg")
for exception excptab
Notes:
- The table has four columns:
actorname VARCHAR(n)
description VARCHAR(m)
url_making_of DATALINK (with LINKTYPE URL)
url_movie DATALINK (with LINKTYPE URL)
- The DATALINK data in the input file has the vertical bar (|)
character as the sub-field delimiter.
- If any column value for url_making_of does not have the prefix
character sequence, "http://narang" is used.
- Each non-NULL column value for url_movie will get "http://bomdel"
as its prefix. Existing values are replaced.
- Each non-NULL column value for url_movie will get ".mpeg"
appended to the path. For example, if a column value of url_movie is
"http://server1/x/y/z", it will be stored as
"http://bomdel/x/y/z.mpeg"; if the value is "/x/y/z", it will be
stored as "http://bomdel/x/y/z.mpeg".
- If any unique index or DATALINK exception occurs while loading the table,
the affected records are deleted from the table and put into the exception
table excptab.
Usage Notes
Data is loaded in the sequence that appears in the input file. If a
particular sequence is desired, the data should be sorted before a load is
attempted.
The load utility builds indexes based on existing definitions. The
exception tables are used to handle duplicates on unique keys. The
utility does not enforce referential integrity, perform constraints checking,
or update summary tables that are dependent on the tables being loaded.
Tables that include referential or check constraints are placed in check
pending state. Summary tables that are defined with REFRESH IMMEDIATE,
and that are dependent on tables being loaded, are also placed in check
pending state. Issue the SET INTEGRITY statement to take the tables out
of check pending state. Load operations cannot be carried out on
replicated summary tables.
If clustering is required, the data should be sorted on the clustering
index prior to loading.
DB2 Data Links Manager Considerations
For each DATALINK column, there can be one column specification within
parentheses. Each column specification consists of one or more of
DL_LINKTYPE, prefix and a DL_URL_SUFFIX
specification. The prefix information can be either
DL_URL_REPLACE_PREFIX, or the DL_URL_DEFAULT_PREFIX
specification.
There can be as many DATALINK column specifications as the number of
DATALINK columns defined in the table. The order of specifications
follows the order of DATALINK columns as found within the insert-column list
(if specified by INSERT INTO (insert-column, ...)), or
within the table definition (if insert-column is not specified).
For example, if a table has columns C1, C2, C3, C4, and C5, and among them
only columns C2 and C5 are of type DATALINK, and the insert-column list is
(C1, C5, C3, C2), there should be two DATALINK column specifications.
The first column specification will be for C5, and the second column
specification will be for C2. If an insert-column list is not
specified, the first column specification will be for C2, and the second
column specification will be for C5.
If there are multiple DATALINK columns, and some columns do not need any
particular specification, the column specification should have at least the
parentheses to unambiguously identify the order of specifications. If
there are no specifications for any of the columns, the entire list of empty
parentheses can be dropped. Thus, in cases where the defaults are
satisfactory, there need not be any DATALINK specification.
If data is being loaded into a table with a DATALINK column that is defined
with FILE LINK CONTROL, perform the following steps before invoking the load
utility. (If all the DATALINK columns are defined with NO LINK CONTROL,
these steps are not necessary).
- Ensure that the DB2 Data Links Manager is installed on the Data Links
servers that will be referred to by the DATALINK column values.
- Ensure that the database is registered with the DB2 Data Links
Manager.
- Copy to the appropriate Data Links servers, all files that will be
inserted as DATALINK values.
- Define the prefix name (or names) to the DB2 Data Links Managers on the
Data Links servers.
- Register the Data Links servers referred to by DATALINK data (to be
loaded) in the DB2 Data Links Manager configuration file.
The connection between DB2 and the Data Links server may fail while running
the load utility, causing the load operation to fail. If this
occurs:
- Start the Data Links server and the DB2 Data Links Manager.
- Invoke a load restart operation.
Links that fail during the load operation are considered to be data
integrity violations, and are handled in much the same way as unique index
violations. Consequently, a special exception has been defined for
loading tables that have one or more DATALINK columns. For additional
information, refer to the description of exceptions in the SQL Reference.
Representation of DATALINK Information
in an Input File
The LINKTYPE (currently only URL is supported) is not specified as part of
DATALINK information. The LINKTYPE is specified in the LOAD or the
IMPORT command, and for input files of type PC/IXF, in the appropriate column
descriptor records as described in the "Export/Import/Load Utility File
Formats" appendix in the Data Movement Utilities Guide and Reference.
The syntax of DATALINK information for a URL LINKTYPE is as follows:
>>-+----------+---+------------------------+-------------------><
'-urlname--' '-dl_delimiter--comment--'
Note that both urlname and comment are optional.
If neither is provided, the NULL value is assigned.
- urlname
- The URL name must conform to valid URL syntax.
Notes:
- Only "http" and "file" are permitted as a scheme name.
- The prefix (scheme, host, and port) of the URL name is optional. If
a prefix is not present, it is taken from the DL_URL_DEFAULT_PREFIX
or the DL_URL_REPLACE_PREFIX specification of the load or the import
utility. If none of these is specified, the prefix defaults to
"file://localhost". Thus, in the case of local files, the file
name with full path name can be entered as the URL name, without the need for
a DATALINK column specification within the LOAD or the IMPORT command.
- Prefixes, even if present in URL names, are overridden by a different
prefix name on the DL_URL_REPLACE_PREFIX specification during a load
or import operation.
- The "path" (after appending DL_URL_SUFFIX, if specified) is the full
path name of the remote file in the remote server. Relative path names
are not allowed. The http server default path-prefix is not taken into
account.
- dl_delimiter
- For the delimited ASCII (DEL) file format, a character specified via the
dldel modifier, or defaulted to on the LOAD or the IMPORT
command. For the non-delimited ASCII (ASC) file format, this should
correspond to the character sequence \; (a backslash followed by a
semicolon). Whitespace characters (blanks, tabs, and so on) are
permitted before and after the value specified for this parameter.
- comment
- The comment portion of a DATALINK value. If specified for the
delimited ASCII (DEL) file format, the comment text must be enclosed
by the character string delimiter, which is double quotation marks (") by
default. This character string delimiter can be overridden by the
MODIFIED BY filetype-mod specification of the LOAD or the IMPORT
command.
If no comment is specified, the comment defaults to a string of length
zero.
Following are DATALINK data examples for the delimited ASCII (DEL) file
format:
- http://www.almaden.ibm.com:80/mrep/intro.mpeg;
"Intro Movie"
This is stored with the following parts:
- scheme = http
- server = www.almaden.ibm.com
- path = /mrep/intro.mpeg
- comment = "Intro Movie"
- file://narang/u/narang; "InderPal's Home Page"
This is stored with the following parts:
- scheme = file
- server = narang
- path = /u/narang
- comment = "InderPal's Home Page"
- file:/home/ff.gg; "hi there"
This is stored with the following parts:
- scheme = file
- server = localhost
- path = /home/ff.gg
- comment = "hi there"
Following are DATALINK data examples for the non-delimited ASCII (ASC) file
format:
- http://www.almaden.ibm.com:80/mrep/intro.mpeg\;Intro
Movie
This is stored with the following parts:
- scheme = http
- server = www.almaden.ibm.com
- path = /mrep/intro.mpeg
- comment = "Intro Movie"
- file://narang/u/narang\; InderPal's Home Page
This is stored with the following parts:
- scheme = file
- server = narang
- path = /u/narang
- comment = "InderPal's Home Page"
- file:/home/ff.gg\; hi there
This is stored with the following parts:
- scheme = file
- server = localhost
- path = /home/ff.gg
- comment = "hi there"
Following are DATALINK data examples in which the load or import
specification for the column is assumed to be DL_URL_DEFAULT_PREFIX
("http://qso"):
Table 7. Valid File Type Modifiers (LOAD)
Modifier
| Description
|
All File Formats
|
anyorder
| This modifier is used in conjunction with the
cpu_parallelism parameter. Specifies that the
preservation of source data order is not required, yielding significant
additional performance benefit on SMP systems. If the value of
cpu_parallelism is 1, this option is ignored. This option
is not supported if SAVECOUNT > 0, since crash recovery after a consistency
point requires that data be loaded in sequence.
|
fastparse
| Reduced syntax checking is done on user-supplied column values, and
performance is enhanced. Tables loaded under this option are guaranteed
to be architecturally correct, and the utility is guaranteed to perform
sufficient data checking to prevent a segmentation violation or trap.
Data that is in correct form will be loaded correctly.
For example, if a value of 123qwr4 were to be encountered as a
field entry for an integer column in an ASC file, the load utility would
ordinarily flag a syntax error, since the value does not represent a valid
number. With fastparse, a syntax error is not detected, and
an arbitrary number is loaded into the integer field. Care must be
taken to use this modifier with clean data only. Performance
improvements using this option with ASCII data can be quite substantial, but
fastparse does not significantly enhance performance with PC/IXF
data, since IXF is a binary format, and fastparse affects parsing
and conversion from ASCII to internal forms.
|
indexfreespace=x
| x is an integer between 0 and 99 inclusive. The value
is interpreted as the percentage of each index page that is to be left as free
space when loading the index. The first entry in a page is added
without restriction; subsequent entries are added if the percent free space
threshold can be maintained. The default value is the one used at
CREATE INDEX time.
This value takes precedence over the PCTFREE value specified in the CREATE
INDEX statement, and affects index leaf pages only.
|
lobsinfile
| lob-path specifies the path to the files containing LOB
values. The ASC, DEL, or IXF load input files contain the names of the
files having LOB data in the LOB column.
|
noheader
| Skips the header verification code.
The AutoLoader utility (see "AutoLoader" in the Data Movement Utilities Guide and Reference) writes a header to each file contributing data to a table in a multi-node
nodegroup. The header includes the node number, the partitioning map,
and the partitioning key specification. The load utility requires this
information to verify that the data is being loaded at the correct
node. When loading files into a table that exists on a single-node
nodegroup, the headers do not exist, and this option causes the load utility
to skip the header verification code.
|
norowwarnings
| Suppresses all warnings about rejected rows.
|
pagefreespace=x
| x is an integer between 0 and 100 inclusive. The value
is interpreted as the percentage of each data page that is to be left as free
space.
If the specified value is invalid because of the minimum row size, (for
example, a row that is at least 3 000 bytes long, and an
x value of 50), the row will be placed on a new page. If a
value of 100 is specified, each row will reside on a new page.
Note: | The PCTFREE value of a table determines the amount of free space designated
per page. If a pagefreespace value on the load operation or
a PCTFREE value on a table have not been set, the utility will fill up as much
space as possible on each page. The value set by
pagefreespace overrides the PCTFREE value specified for the
table.
|
|
totalfreespace=x
| x is an integer between 0 and 100 inclusive. The value
is interpreted as the percentage of the total pages in the table that is to be
appended to the end of the table as free space. For example, if
x is 20, and the table has 100 data pages, 20 additional empty
pages will be appended. The total number of data pages for the table
will be 120.
|
usedefaults
| If a source column for a target table column has been specified, but it
contains no data for one or more row instances, default values are
loaded. Examples of missing data are:
- For DEL files: ",," is specified for the column
- For DEL/ASC/WSF files: A row that does not have enough columns, or
is not long enough for the original specification.
instance, one of the following occurs:
- If the column is nullable, a NULL is loaded
- If the column is not nullable, the utility rejects the row.
|
ASCII File Formats (ASC/DEL)
|
codepage=x
| x is an ASCII character string. The value is
interpreted as the code page of the data in the input data set.
Converts character data (and numeric data specified in characters) from this
code page to the database code page during the load operation.
The following rules apply:
- For pure DBCS (graphic), mixed DBCS, and EUC, delimiters are restricted to
the range of x00 to x3F, inclusive.
- For DEL data specified in an EBCDIC code page, the delimiters may not
coincide with the shift-in and shift-out DBCS characters.
- nullindchar must specify symbols included in the standard ASCII
set between code points x20 and x7F, inclusive. This refers to ASCII
symbols and code points. EBCDIC data can use the corresponding symbols,
even though the code points will be different.
|
dumpfile = x
| x is the fully qualified (according to the server node) name
of an exception file to which rejected rows are written. A maximum of
32KB of data is written per record. Following is an example that shows
how to specify a dump file:
db2 load from data of del
modified by dumpfile = /u/user/filename
insert into table_name
Notes:
- In a partitioned database environment, the path should be local to the
loading node, so that concurrently running load operations do not attempt to
write to the same file.
- The contents of the file are written to disk in an asynchronous buffered
mode. In the event of a failed or an interrupted load operation, the
number of records committed to disk cannot be known with certainty, and
consistency cannot be guaranteed after a LOAD RESTART. The file can
only be assumed to be complete for a load operation that starts and completes
in a single pass.
- This modifier does not support file names with multiple file
extensions. For example,
dumpfile = /home/svtdbm6/DUMP.FILE
is acceptable to the load utility, but
dumpfile = /home/svtdbm6/DUMP.LOAD.FILE
is not.
|
implieddecimal
| The location of an implied decimal point is determined by the column
definition; it is no longer assumed to be at the end of the value. For
example, the value 12345 is loaded into a DECIMAL(8,2) column as
123.45, not 12345.00.
|
noeofchar
| The optional end-of-file character x'1A' is not
recognized as the end of file. Processing continues as if it were a
normal character.
|
ASC (Non-delimited ASCII) File Format
|
binarynumerics
| Numeric (but not DECIMAL) data must be in binary form, not the character
representation. This avoids costly conversions.
This option is supported only with positional ASC, using fixed length
records specified by the reclen option. The
noeofchar option is assumed.
The following rules apply:
- No conversion between data types is performed, with the exception of
BIGINT, INTEGER, and SMALLINT.
- Data lengths must match their target column definitions.
- FLOATs must be in IEEE Floating Point format.
- Binary data in the load source file is assumed to be big-endian,
regardless of the platform on which the load operation is running.
Note: | NULLs cannot be present in the data for columns affected by this
modifier. Blanks (normally interpreted as NULL) are interpreted as a
binary value when this modifier is used.
|
|
nochecklengths
| If nochecklengths is specified, an attempt is made to load
each row, even if the source data has a column definition that exceeds the
size of the target table column. Such rows can be successfully loaded
if code page conversion causes the source data to shrink; for example, 4-byte
EUC data in the source could shrink to 2-byte DBCS data in the target, and
require half the space. This option is particularly useful if it is
known that the source data will fit in all cases despite mismatched column
definitions.
|
nullindchar=x
| x is a single character. Changes the character denoting
a NULL value to x. The default value of x is
Y.b
This modifier is case sensitive for EBCDIC data files, except when the
character is an English letter. For example, if the NULL indicator
character is specified to be the letter N, then n is
also recognized as a NULL indicator.
|
packeddecimal
| Loads packed-decimal data directly, since the binarynumerics
modifier does not include the DECIMAL field type.
This option is supported only with positional ASC, using fixed length
records specified by the reclen option. The
noeofchar option is assumed.
Supported values for the sign nibble are:
+ = 0xC 0xA 0xE 0xF
- = 0xD 0xB
Note: | NULLs cannot be present in the data for columns affected by this
modifier. Blanks (normally interpreted as NULL) are interpreted as a
binary value when this modifier is used.
Regardless of the server platform, the byte order of binary data in the
load source file is assumed to be big-endian; that is, when using this
modifier on OS/2 or on the Windows operating system, the byte order must
not be reversed.
|
|
reclen=x
| x is an integer with a maximum value of
32 767. x characters are read for each row, and a
new-line character is not used to indicate the end of the row.
|
striptblanks
| Truncates any trailing blank spaces when loading data into a
variable-length field. If this option is not specified, blank spaces
are kept.
This option cannot be specified together with
striptnulls. These are mutually exclusive options.
Note: | This option replaces the obsolete t option, which is supported for
back-level compatibility only.
|
|
striptnulls
| Truncates any trailing NULLs (0x00 characters) when loading data into a
variable-length field. If this option is not specified, NULLs are
kept.
This option cannot be specified together with
striptblanks. These are mutually exclusive options.
Note: | This option replaces the obsolete padwithzero option, which is
supported for back-level compatibility only.
|
|
DEL (Delimited ASCII) File Format
|
chardelx
| x is a single character string delimiter. The default
value is a double quotation mark ("). The specified character is
used in place of double quotation marks to enclose a character
string.ab
The single quotation mark (') can also be specified as a character
string delimiter as follows:
modified by chardel''
|
coldelx
| x is a single character column delimiter. The default
value is a comma (,). The specified character is used in place of
a comma to signal the end of a column.ab
|
datesiso
| Date format. Causes all date data values to be loaded in ISO
format.
|
decplusblank
| Plus sign character. Causes positive decimal values to be prefixed
with a blank space instead of a plus sign (+). The default action
is to prefix positive decimal values with a plus sign.
|
decptx
| x is a single character substitute for the period as a decimal
point character. The default value is a period (.). The
specified character is used in place of a period as a decimal point
character.ab
|
delprioritychar
| The current default priority for delimiters is: record delimiter,
character delimiter, column delimiter. This modifier protects existing
applications that depend on the older priority by reverting the delimiter
priorities to: character delimiter, record delimiter, column
delimiter. Syntax:
db2 load ... modified by delprioritychar ...
For example, given the following DEL data file:
"Smith, Joshua",4000,34.98<row delimiter>
"Vincent,<row delimiter>, is a manager", ...
... 4005,44.37<row delimiter>
With the delprioritychar modifier specified, there will be only
two rows in this data file. The second <row delimiter> will be
interpreted as part of the first data column of the second row, while the
first and the third <row delimiter> are interpreted as actual record
delimiters. If this modifier is not specified, there will be
three rows in this data file, each delimited by a <row
delimiter>.
|
dldelx
| x is a single character DATALINK delimiter. The default
value is a semicolon (;). The specified character is used in place
of a semicolon as the inter-field separator for a DATALINK value. It is
needed because a DATALINK value may have more than one sub-value.
abc
Note: | x must not be the same character specified as the row, column, or
character string delimiter.
|
|
nodoubledel
| Suppresses recognition of double character delimiters.
|
IXF File Format
|
forcein
| Directs the utility to accept data despite code page mismatches, and to
suppress translation between code pages.
Fixed length target fields are checked to verify that they are large enough
for the data. If nochecklengths is specified, no checking is
done, and an attempt is made to load each row.
|
nochecklengths
| If nochecklengths is specified, an attempt is made to load
each row, even if the source data has a column definition that exceeds the
size of the target table column. Such rows can be successfully loaded
if code page conversion causes the source data to shrink; for example, 4-byte
EUC data in the source could shrink to 2-byte DBCS data in the target, and
require half the space. This option is particularly useful if it is
known that the source data will fit in all cases despite mismatched column
definitions.
|
Notes:
- The load utility does not issue a warning if an attempt is made to use
unsupported file types with the MODIFIED BY option. If this is
attempted, the load operation fails, and an error code is returned.
- a Delimiter Restrictions lists restrictions that apply to the characters that can be
used as delimiter overrides.
- b The character must be specified in the code page of the
source data.
The character code point (instead of the character symbol), can be
specified using the syntax xJJ or 0xJJ, where JJ is the hexadecimal
representation of the code point. For example, to specify the #
character as a column delimiter, use one of the following:
... modified by coldel# ...
... modified by coldel0x23 ...
... modified by coldelX23 ...
- c Even if the DATALINK delimiter character is a valid character
within the URL syntax, it will lose its special meaning within the scope of
the load operation.
|
See Also
LOAD QUERY
QUIESCE TABLESPACES FOR TABLE.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
[ DB2 List of Books |
Search the DB2 Books ]