[ Team LiB ] |
Load UtilityThe LOAD UTILITY is used to load data into a DB2 table. Data residing on the server may be in the form of a file, tape, or named pipe. Data residing on a remotely connected client may be in the form of a fully qualified file or named pipe. New in v8, data can also be loaded from a user-defined cursor. The load utility does not support loading data at the hierarchy level. As indicated in Figure 7.7, the Load Wizard can assist you in quickly loading data into tables. Figure 7.7. Load Wizard example.As with all of the DB2 wizards, the Load Wizard can help you to load data quickly and seamlessly, resulting in improved productivity. ScopeThis command may be issued against multiple database partitions in a single request. AuthorizationOne of the following:
NOTE Since all load process (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 connectionDatabase: NOTE In v8, the LOAD UTILITY now operates at the table level instead of the tablespace level. This enhancement enables DB2 to deliver higher degrees of availability than ever before and is a welcomed enhancement in the field. Command ParametersALLOW NO ACCESSLoad will lock the target table for exclusive access during the load. The table state will be set to LOAD IN PROGRESS during the load. ALLOW NO ACCESS is the default behavior. It is the only valid option for LOAD REPLACE. When there are constraints on the table, the table state will be set to CHECK PENDING as well as LOAD IN PROGRESS. The SET INTEGRITY command must be used to take the table out of CHECK PENDING. ALLOW READ ACCESSLoad will lock the target table in a share mode. The table state will be set to both LOAD IN PROGRESS and READ ACCESS. Readers may access the nondelta portion of the data while the table is being loaded. In other words, data that existed before the start of the load will be accessible by readers to the table; data that is being loaded is not available until the load is complete. LOAD TERMINATE or LOAD RESTART of an ALLOW READ ACCESS load may use this option; LOAD TERMINATE or LOAD RESTART of an ALLOW NO ACCESS load may not use this option. Furthermore, this option is not valid if the indexes on the target table are marked as requiring a rebuild. When there are constraints on the table, the table state will be set to CHECK PENDING as well as LOAD IN PROGRESS and READ ACCESS. At the end of the load the table state LOAD IN PROGRESS will be removed but the table states CHECK PENDING and READ ACCESS will remain. The SET INTEGRITY command must be used to take the table out of CHECK PENDING. While the table is in CHECK PENDING and READ ACCESS, the nondelta portion of the data is still accessible to readers, the new (delta) portion of the data will remain inaccessible until the SET INTEGRITY command has completed. A user may perform multiple loads on the same table without issuing a SET INTEGRITY command. Only the original (checked) data will remain visible, however, until the SET INTEGRITY command is issued. ALLOW READ ACCESS also supports the following modifiers:
CHECK PENDING CASCADEIf LOAD puts the table into a check pending state, the CHECK PENDING CASCADE option allows the user to specify whether or not the check pending state of the loaded table is immediately cascaded to all descendents (including descendent foreign key tables, and immediate staging tables). IMMEDIATEIndicates that the check pending state (read or no access mode) for foreign key constraints is immediately extended to all descendent foreign key tables. If the table has descendent immediate materialized query tables or descendent immediate staging tables, the check pending state is extended immediately to the materialized query tables and the staging tables. Note that for a LOAD INSERT operation, the check pending state is not extended to descendent foreign key tables even if the IMMEDIATE option is specified. When the loaded table is later checked for constraint violations (using the IMMEDIATE CHECKED option of the SET INTEGRITY statement), descendent foreign key tables that were placed in check, pending a read state, will be put into check pending no access state. DEFERREDIndicates that only the loaded table will be placed in the check pending state (read or no access mode). The states of the descendent foreign key tables, descendent immediate materialized query tables, and descendent immediate staging tables will remain unchanged. Descendent foreign key tables may later be implicitly placed in the check pending no access state when their parent tables are checked for constraint violations (using the IMMEDIATE CHECKED option of the SET INTEGRITY statement). Descendent immediate materialized query tables and descendent immediate staging tables will be implicitly placed in the check pending no access state when one of its underlying tables is checked for integrity violations. A warning (SQLSTATE 01586) will be issued to indicate that dependent tables have been placed in the check pending state. See the Notes section of the SET INTEGRITY statement in the SQL Reference for when these descendents tables will be put into the check pending state. If the CHECK PENDING CASCADE option is not specified:
CLIENTSpecifies that the data to be loaded resides on a remotely connected client. This option is ignored if the load operation is not being invoked from a remote client. This option is not supported in conjunction with the CURSOR filetype. Notes
In the following example, a data file (/u/user/data.del) residing on a remotely connected client is to be loaded into MYTABLE on the server database:
COPY NOSpecifies that the tablespace in which the table resides will be placed in backup pending state if forward recovery is enabled (i.e., logretain or userexit is on). Copy no will also put the tablespace state into the Load in Progress tablespace state. This is a transient state that will disappear when the load completes or aborts. The data in any table in the tablespace cannot be updated or deleted until a tablespace backup or a full database backup is made. However, it is possible to access the data in any table by using the SELECT statement. COPY YESSpecifies 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.
CPU_PARALLELISM nSpecifies 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 intrapartition 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 (usually based on the number of CPUs available) at run time. Notes
DATA BUFFER buffer-sizeSpecifies the number of 4 KB 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. DISK_PARALLELISM nSpecifies the number of processes or threads that the load utility will spawn for writing data to the tablespace containers. If a value is not specified, the utility selects an intelligent default based on the number of tablespace containers and the characteristics of the table. FOR EXCEPTION table-nameSpecifies 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. If an unqualified table name is specified, the table will be qualified with the CURRENT SCHEMA. Information that is written to the exception table is not written to the dump file. In a partitioned database environment, an exception table is defined for those partitions 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. FROM filename/pipename/device/cursornameSpecifies the file, pipe, device, or cursor referring to an SQL statement that contains the data being loaded. If the input source is a file, pipe, or device, it must reside on the database partition where the database resides, unless the CLIENT option is specified. 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
Notes
INDEXING MODESpecifies whether the load utility is to rebuild indexes or to extend them incrementally. Valid values are:
LOCK WITH FORCEThe utility acquired various locks, including table locks, in the process of loading. Rather than wait, and possibly timeout, when acquiring a lock, this option allows the load to force off other applications that hold conflicting locks. Forced applications will roll back and release the locks the load utility needs. The load utility can then proceed. This option requires the same authority as the FORCE APPLICATIONS command (SYSADM or SYSCTRL). NOTE The new LOCK WTH FORCE option enables a load utility to force applications holding locks that are preventing a load from completing. ALLOW NO ACCESS loads may force applications holding conflicting locks at the start of the load operation. At the start of the load the utility may force applications that are attempting to either query or modify the table. ALLOW READ ACCESS loads may force applications holding conflicting locks at the start or end of the load operation. At the start of the load the load utility may force applications that are attempting to modify the table. At the end of the load the load utility may force applications that are attempting to either query or modify the table. MESSAGES message-fileSpecifies 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. The message file is usually populated with messages at the end of the load operation and, as such, is not suitable for monitoring the progress of the operation. METHOD
MODIFIED BY filetype-modSpecifies additional options. NONRECOVERABLESpecifies that the load transaction is to be marked as nonrecoverable and that it will not be possible to recover it by subsequent roll-forward action. The roll-forward 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 operation is completed, such a table can only be dropped or restored from a backup (full or tablespace) taken after a commit point following the completion of the nonrecoverable load operation. With this option, tablespaces 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 null-indicate-listThis option can only be used when the METHOD L parameter is specified; that is, the input file is an ASC file. The null indicator list is a comma-separated list of positive integers specifying the column number of each null indicator field. The column number is the byte offset of the null indicator field from the beginning of a row of data. There must be one entry in the null indicator list for each data field defined in the METHOD L parameter. A column number of zero indicates that the corresponding data field always contains data. 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. OF filetypeSpecifies the format of the data:
REPLACEOne 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. RESTARTOne 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. RESTARTCOUNTReserved. ROWCOUNT nSpecifies 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 nSpecifies 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 the activities performed at each consistency point will impact performance. The default value is zero, meaning that no consistency points will be established, unless necessary. This option is not supported in conjunction with the CURSOR filetype. SORT BUFFER buffer-sizeThis option specifies a value that overrides the SORTHEAP database configuration parameter during a load operation. It is relevant only when loading tables with indexes and only when the INDEXING MODE parameter is not specified as DEFERRED. The value that is specified cannot exceed the value of SORTHEAP. This parameter is useful for throttling the sort memory that is used when loading tables with many indexes without changing the value of SORTHEAP, which would also affect general query processing. STATISTICS NOSpecifies that no statistics are to be collected, and that the statistics in the catalogs are not to be altered. This is the default. STATISTICS YESSpecifies 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.
TEMPFILES PATH temp-pathnameSpecifies 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 database partition. 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:
TERMINATEOne of four modes under which the load utility can execute. Terminates a previously interrupted load operation to the point in time at which it started, even if consistency points were passed. The states of any tablespaces 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. The load terminate option will not remove a backup pending state from tablespaces. NOTE This option is not supported for tables with DATALINK columns. USING directoryThis option has been reserved for future use. WARNINGCOUNT nStops 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 PROMPTINGSpecifies 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 as 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. |
[ Team LiB ] |
No comments:
Post a Comment