To move data, you can use the load, import, and export utilities. The following sections describe considerations for using these utilities with DB2 File Manager data.
For information about the file formats that you can use with these utilities, see the Command Reference.
Use the load utility for the initial load or an append of a table where large amounts of data are moved. The LOAD command is faster than the IMPORT command, because it writes formatted pages directly into the database while IMPORT performs SQL INSERTs.
If you are loading data to a table with a DATALINK column that is defined as 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.)
It is possible that while running the load utility, the connection between DB2 and the file server may fail. This causes the load to fail. If this occurs:
Any links that fail during the load process are considered to be a type of data integrity violation, and they are handled in much the same way as violations of unique constraints. Consequently an exception is defined that can occur only if the table under load has one or more DATALINK columns. For additional information, refer to the description of exceptions in the SQL Reference.
All the database data for a table resides in the database, while the files referred to by DATALINK columns reside on file servers. The EXPORT utility has to move both the database data, and the data files on the corresponding file servers. To do this, the EXPORT utility produces one control file per file server. The name of the control file that is created is the same as the name of the file server (for example, the control file for the file server fs1 is "fs1"). The control files are created in a newly created directory that has the name dlfmYYYY, where YYYY is a system-generated pattern. This directory is created under the same directory where the EXPORT datafile is created.
A control file lists the names of the corresponding DB2 File Manager files that are referenced by the DATALINK columns of rows that are exported. DATALINK values that have the "no link" control property are not placed in the control file.
You issue the dlfm_export command at each file server, and specify the control file that was generated for that file server. The dlfm_export command produces an archive of the files listed in the control file.
To ensure that a consistent copy of the table and the corresponding files that are referenced by the DATALINK columns are copied for export, perform the following steps:
QUIESCE TABLESPACES FOR TABLE tablename SHARE
QUIESCE TABLESPACES FOR TABLE tablename RESET
The EXPORT utility executes as an SQL application. The rows and columns that satisfy the select-statement conditions are extracted from the database. For the DATALINK columns, the select-statement should not specify any scalar function. The EXPORT utility extracts parts of the DATALINK value, such as the link type, file server name, file path name, and comments.
When the EXPORT utility executes successfully, the following files are generated:
Use the dlfm_export utility to export files from a file server as follows:
dlfm_export control_file_name tar_file_name
where control_file_name is the file name generated by running the EXPORT utility on the DB2 client; and, tar_file_name is the name of the archive file that will be generated. The default tar_file_name is "export.tar" in the current working directory.
A corresponding utility called dlfm_import is provided to retrieve and restore files from the archive that dlfm_export generates. This utility must be used whether the archived files are being restored on the same, or a different, file server.
Use the dlfm_import utility to retrieve files from the archive as follows:
where tar_file_name is the name of the archive file that will be used to recover the files. The default tar_file_name is "export.tar" in the current working directory.
The figure below shows how to export the DB2 data and the files that are
referenced by the instance called "SystemA" to the instance called
"SystemB". SystemA uses the file servers DLFM1 and DLFM2.
SystemB uses the file servers DLFMX and DLFMY. The files on DLFM1 will
be exported to DLFMX and the DLFM2 files will be exported to DLFMY.
|InstanceA with File Servers DLFM1 and DLFM2||Step|
|DB2 Data on File||File1 with filename for DLFM1||File2 with filename for DLFM2||1) Run the dlfm_export command (as root) on both file servers. This will produce an archive on both file servers.|
|InstanceB with File Servers DLFMX and DLFMY||
||On DLFMX, restore from archive||On DLFMY, restore from archive||2) Run dlfm_import (as root) on both file servers|
||3) Run the IMPORT command on InstanceB with the parameter DL_URL_REPLACE_PREFIX to specify the appropriate file server for each exported file.|
|After you run the import utility on InstanceB, the InstanceA data and all files referenced by DATALINK columns are now imported.|
All the database data for a table resides within the database, while the files referred to in the DATALINK columns reside on the file servers. The import utility has to move both the database data, and the files on the corresponding file servers.
Before running the import utility in the target database, you should perform the following steps:
Then run the import utility in the target database system.
When the import utility executes on the target database, data related to DATALINK columns (and the other columns) is loaded into the underlying tables using SQL INSERT. During the INSERT, the DATALINK column is linked to the file on the appropriate file server.
[ DB2 List of Books | Search the DB2 Books ]