Operation Example of data Transfer task under DB2

Source: Internet
Author: User
Tags command line db2 one table

Simplifies the data transfer process of DB2 for Linux, UNIX, and Windows using the From CURSOR option of the DB2 LOAD utility. This article describes the LOAD from CURSOR feature and provides an example of the use of two interface Command line Processor and admin_cmd stored procedures.

Brief introduction

A typical DB2 data transfer task involves three steps:

Export data from the source database to a temporary data interchange file in binary or text format

Transferring generated files between systems

Import or mount data from a file into the target database

In the case of large amounts of data, it often takes a long time to generate a data interchange file using the EXPORT utility. In addition, different database coding pages and operating systems must be considered when moving data into and out of the database.

You can use the LOAD utility's from CURSOR option to avoid these problems. When the From CURSOR option is specified, the load utility directly takes the result set of an SQL query as the source of the data load operation, so that no temporary data interchange file is required. Therefore, the LOAD from CURSOR is a quick and easy way to transfer data between different table spaces or databases. You can perform the LOAD from CURSOR on the command line, or you can execute it in an application or stored procedure by using a DB2 admin_cmd stored procedure. This article describes the LOAD from CURSOR feature and provides an example of the use of two interface Command line Processor (CLP) and admin_cmd stored procedures.

Transfer a table to another table space

First, see How to move a table from one table space to another table space. You may need to perform this data transfer if the page size of the table space in which you create the table is not appropriate, or if you should access the table with another buffer pool. In DB2 versions prior to 9.1, tables were often transferred between tablespaces due to the maximum size of the table space. However, in DB2 9.1 and later, this should no longer be a problem, because the table space size limit has been significantly increased (provided that you use large table space instead of the regular tablespace used previously).

This example scenario first creates the DB2 sample database. This can be done by invoking the Db2sampl command at the command line, as shown in Listing 1.

Listing 1. Create a SAMPLE database

C:\>db2sampl
Creating database "SAMPLE"...
Connecting to database "SAMPLE"...
Creating  tables and data in schema "FECHNER"...
'db2sampl' processing complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.