IBM Books

Administration Getting Started


Step 2. Moving Data Into a Table

DB2 provides the import and load utilities to help you move data into a table from existing sources. Another method of moving data into a database is replication, described briefly in "Replicating Data".

Manual entry of data into your database can be done either with SQL commands, described in the SQL Reference; Lotus Approach, described in the Using Lotus Approach with DB2 booklet (provided in the product box with DB2); or an application.

The import utility takes data from an input file and inserts it into a table or view. This input file would contain data that was extracted from an existing source of data, such as a Lotus 1-2-3 file or an ASCII file. DB2 imports file formats generated from the supported sources listed in "Importing Data into a Table or View". However, the procedure for generating each of these files will vary with the original source. For details on generating the appropriate input file format, refer to the documentation accompanying the source product.

You can also use the import utility to re-create a table or view that was saved by using the export utility. See the Administration Guide for more information on import and export.

This section provides the steps for importing data. A brief overview of the other two methods is provided.

Importing Data into a Table or View

Once you have an input file available in a supported format, use the Import notebook to insert data from the file into an existing table. If this table already contains data, you can either replace or append to the existing data with the data in the file.

You can also use the Import notebook to create a new table that is populated by an input file, or delete existing rows in the selected table and repopulate it using data from the input file.

The online help provides details on how to complete all the optional and required fields.

To import a file into an existing table:

  1. From the Control Center, expand the object tree until you find the Tables folder.

  2. Click on the Tables folder. Any existing tables are displayed in the contents pane.

  3. Click mouse button 2 on the table you want in the contents pane and select Import from the pop-up menu. The Import notebook opens with the File page displayed.

  4. Specify file options.

    Use the File page of the Import notebook to specify the file and type of file you want to import:

    1. In the Import file field, enter the name of the file that contains the data you want to import.

    2. Specify the type of file to import by selecting one of the following radio buttons:

      • Non-delimited ASCII format (ASC)

        Non-delimited ASCII data is data that is aligned in columns.

      • Delimited ASCII format (DEL)

        Delimited ASCII data is a commonly used way of storing data that separates column values with a user-defined delimiting character such as a comma.

      • Worksheet format (WSF)

      • Integrated exchange format (IXF)

        PC/IXF is a structured description of a database table or view. Data that was exported in PC/IXF format can be imported or loaded into another DB2 Universal Database product database.

      See the online help for the specific products and releases that are supported.

    3. Optional: Specify file type modifiers by clicking on the corresponding Options push button. The Options window for that format opens.

    4. Select the Import mode you want to use. The available import modes vary depending on the file type you selected.

    5. Optional: In the Commit records field, enter the number of records to import before the changes are committed.

    6. Optional: In the Restart field, enter the number of records in the file to skip before beginning the import.

    7. Optional: In the Compound field, type a number to specify how many SQL statements will be executed (in an executable block).

    8. Optional: Select the Insert an implied decimal point on decimal data (IMPLIEDDECIMALPOINT) check box.

    9. In the Message file field, type the name of the file that will contain warning and error messages that occur during import.

  5. Optional: Retrieve large objects from separate files.

    Use the Large Objects page of the Import notebook to retrieve large objects (LOBs) from the path or paths that store the LOB files:

    1. Click on the Retrieve large objects (LOBs) in separate files (LOBSINFILE) check box to enable the options on the Large Objects page.

    2. Specify the location of separate LOB files in the LOB paths list box by clicking on the Add push button. These paths are searched (in the order in which they appear in the LOB paths list box) for the LOB files specified in the LOB column of the input file.

    3. Click on OK to accept the defaults on the other notebook pages and begin the import process.

  6. Optional: Specify column import options.

    Use the Columns page of the Import notebook to specify column import options:

    1. Click on one of the radio buttons in the Include columns by box to specify the column method that will be used to import data file columns into the table. The available methods vary depending on the file type and mode you selected on the File page.

    2. Optional: Specify or change the import file column attributes by clicking on the Change push button.

      This option is not available if you selected the Default (method D) radio button.

  7. Click on OK to accept the parameters specified in this notebook and begin the import process.

Using the Load Utility to Load Data Quickly

The load utility loads data directly into a DB2 table from one or more files, tapes and other devices, or named pipes. For example, you might be required to move in data from databases other than DB2. For a description of the functional differences between the load utility and the import utility, see the Administration Guide.

During load processing, indexes can be built, primary keys, unique keys, and unique indexes validated, and many statistics generated, all without requiring secondary passes through the data. The load utility is faster than the import utility, and supports the loading of all data types (excluding worksheet format). It is intended for either bulk loading of new tables or appending large amounts of data to existing tables.

Replicating Data

Replication is the process of taking changes stored in the database log at the source server and applying them to the target server. You can use replication to define, synchronize, automate, and manage copy operations for data across your enterprise. You can automatically deliver the data from a host system to target sites. For example, you can copy data and applications to branch offices, retail outlets, and even sales representatives' laptops.

The two operational components in replication are Capture and Apply. The Capture component captures changes made to data in source tables which have been defined for replication by reading the database log. The Apply component reads the changed data previously captured and stored in a change data table and applies it to the target tables.

Using the Control Center you can do the setup required for replication using the Define as replication source and Define subscription actions. The replication components Capture and Apply run outside the DB2 administration tools.

Replication administrators can perform the following from the Control Center:

The high-level steps for replicating data are as follows. See the Replication Guide and Reference for details.

  1. Design a replication scenario (map the source and target tables)

  2. Define a replication source (this relates to the capture action):
    1. Specify source columns to capture
    2. Choose replication options

  3. Define a replication subscription (this relates to the apply action):
    1. Name the subscription set
    2. Specify the database and target table
    3. Specify the target columns
    4. Specify the row selection
    5. Specify SQL for run-time processing
    6. Set the subscription timing

  4. Alter source table with Data Capture Changes option

  5. Start Capture to read and store data changes

  6. Start Apply to replicate changes to target tables


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]