RedBook DB2 sg246905
RedBook DB2 sg246905
Paolo Bruni
Michael Ho
Marko Milek
Arne Nilsen
Jose Mari Michael Sanchez
ibm.com/redbooks
International Technical Support Organization
February 2003
SG24-6905-00
Note: Before using this information and the product it supports, read the information in “Notices” on
page xvii.
This edition applies to DB2 UDB for z/OS Version 7 (Program Number 5675-DB2), DB2 Version 7
Utilities Suite (Program Number 5697-E98), DB2 UDB V7.2 for Linux, UNIX, and Windows (Program Number
5648-D37) and the pre-GA (beta) DB2 UDB V8.1 for Linux, UNIX, and Windows (Program Number 5765-F34),
High Performance Unload for z/OS Version 2 Release 1 (Program Number 5655-I19) and High Performance
Unload for Multiplatforms Version 2 Release 1 Modification 2 and 3 (Program Number 5724-B90.)
Note: This book is based on a pre-GA version of a product and may not apply when the product becomes
generally available. We recommend that you consult the product documentation or follow-on versions of
this redbook for more current information.
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
The team that wrote this redbook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Become a published author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Comments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xx
Part 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.0.1 Platforms and configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.0.2 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1 Contents of this redbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Contents v
10.3 Moving data between two DB2 for z/OS databases . . . . . . . . . . . . . . . . . . . . . . . . . 251
10.3.1 Using Cross Loader to move data from/to DB2 for z/OS . . . . . . . . . . . . . . . . . 251
10.3.2 Data Propagator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
10.3.3 Unload and Load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
10.3.4 HPU for z/OS and Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
10.3.5 SQL Insert with subselect in a Federated Database. . . . . . . . . . . . . . . . . . . . . 264
10.4 Summary and conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
10.4.1 From distributed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
10.4.2 From mainframe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
10.4.3 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Contents vii
viii Moving Data Across the DB2 Family
Figures
Examples xiii
xiv Moving Data Across the DB2 Family
Tables
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult
your local IBM representative for information on the products and services currently available in your area. Any
reference to an IBM product, program, or service is not intended to state or imply that only that IBM product,
program, or service may be used. Any functionally equivalent product, program, or service that does not
infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to
evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this document. The
furnishing of this document does not give you any license to these patents. You can send license inquiries, in
writing, to:
IBM Director of Licensing, IBM Corporation, North Castle Drive Armonk, NY 10504-1785 U.S.A.
The following paragraph does not apply to the United Kingdom or any other country where such
provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION
PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of
express or implied warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made
to the information herein; these changes will be incorporated in new editions of the publication. IBM may make
improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time
without notice.
Any references in this information to non-IBM Web sites are provided for convenience only and do not in any
manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the
materials for this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring
any obligation to you.
Information concerning non-IBM products was obtained from the suppliers of those products, their published
announcements or other publicly available sources. IBM has not tested those products and cannot confirm the
accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the
capabilities of non-IBM products should be addressed to the suppliers of those products.
This information contains examples of data and reports used in daily business operations. To illustrate them
as completely as possible, the examples include the names of individuals, companies, brands, and products.
All of these names are fictitious and any similarity to the names and addresses used by an actual business
enterprise is entirely coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which illustrates programming
techniques on various operating platforms. You may copy, modify, and distribute these sample programs in
any form without payment to IBM, for the purposes of developing, using, marketing or distributing application
programs conforming to the application programming interface for the operating platform for which the sample
programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore,
cannot guarantee or imply reliability, serviceability, or function of these programs. You may copy, modify, and
distribute these sample programs in any form without payment to IBM for the purposes of developing, using,
marketing, or distributing application programs conforming to IBM's application programming interfaces.
ActionMedia, LANDesk, MMX, Pentium and ProShare are trademarks of Intel Corporation in the United
States, other countries, or both.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the
United States, other countries, or both.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems,
Inc. in the United States, other countries, or both.
C-bus is a trademark of Corollary, Inc. in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
SET, SET Secure Electronic Transaction, and the SET Logo are trademarks owned by SET Secure Electronic
Transaction LLC.
Other company, product, and service names may be trademarks or service marks of others.
Moving data across different databases and even different platforms has been a common
task in IT shops for quite some time. Applications may have been developed independently
and over time, using packages and different technology; and data might reside on different
platforms exploiting the specific platform strong points. However, there still is a growing need
for applications that need to access all of this data for overall processing.
While new Web related technologies are emerging with the intent to provide functions to
collect and integrate information across multiple databases and applications for access in real
time, moving data to one location for overall processing is still a very common requirement.
This IBM Redbook provides an overview of what is currently available within the DB2 Family
of products (specifically DB2 for z/OS, and DB2 for UNIX and Windows) in terms of functions,
tools, and utilities to satisfy the need for moving data. We focus on discussing High
Performance Unload and Cross Loader; the first one is a tool, the second one is a new option
of the Load utility, since they are the latest functions that IBM has released. We also introduce
the concepts and some examples of using the Federated Database support.
Paolo Bruni has been a Project Leader since 1998 at the International Technical Support
Organization, San Jose Center, where he conducts projects on all areas of Data
Management. During his many years with IBM, in development and in the field, Paolo’s work
has been mainly related to database systems.
Michael Ho is a Software Engineer at the IBM Toronto Laboratory in Canada. He has four
years of experience in database development. Michael holds a BS degree from the University
of Toronto. His areas of expertise include the Load, Import, and Export utilities for DB2 UDB
on distributed platforms.
Marko Milek is a Software Engineer at the IBM Toronto Laboratory in Canada. He has two
years of experience in database development. Marko holds a bachelor's degree from the
California Institute of Technology, and a Ph.D. from McGill University. His areas of expertise
include utilities and tools for DB2 UDB on distributed platforms.
Arne Nilsen is a Database Administrator in ErgoSolutions in Oslo, Norway. He has more than
15 years of experience in data management. Arne has an extensive knowledge in most areas
of DB2 gained through his wide experience in the field. During the last several years he has
been involved in system design, integration, and security.
Jose Mari Michael Sanchez is an IT Specialist for IBM Global Services in the Philippines. He
has 6 years of experience in the data management field. He started as an application
developer and then became a DB2 technical support and system programmer for OS/390.
Michael holds a BS in Applied Physics from the University of the Philippines. He is an IBM
Certified Solution Expert for DB2 UDB V7 Database Administration.
Rich Conway
International Technical Support Organization, Poughkeepsie Center
Dinesh Nirmal
Jim Ruddy
Dave Schwartz
Randy Spalten
Don Weil
IBM Silicon Valley Laboratory
Mark Leitch
IBM Toronto Laboratory
Norbert Thiebaud
Infotel
Your efforts will help increase product acceptance and customer satisfaction. As a bonus, you
will develop a network of contacts in IBM development labs, and increase your productivity
and marketability.
Find out more about the residency program, browse the residency index, and apply online at:
ibm.com/redbooks/residencies.html
Comments welcome
Your comments are important to us!
We want our Redbooks to be as helpful as possible. Send us your comments about this or
other Redbooks in one of the following ways:
Use the online Contact us review redbook form found at:
ibm.com/redbooks
Send your comments in an Internet note to:
[email protected]
Mail your comments to:
IBM Corporation, International Technical Support Organization
Dept. QXXE Building 80-E2
Preface xxi
xxii Moving Data Across the DB2 Family
Part 1
Part 1 Introduction
In this part we introduce the possible reasons for moving data across the DB2 subsystems
and the different platforms, the objectives of our project, and the contents of this redbook, as
well as provide a summary of the functions and tools that can help in this area.
Chapter 1. Introduction
Moving data across different databases and different platforms has been a common task in IT
shops for quite some time. By moving data we mainly refer to the task of copying data from a
source system to a target system, not necessarily removing it at the source location. While
relational databases, and especially the DB2 Family of products, might have the same look
and feel, each platform has its own strengths and advantages. So, data in a typical database
shop will most probably reside in different platforms. There are also many instances of
companies merging for business reasons, each one with an IT shop with its own
characteristics, where the applications need to access all of this data even if they reside in
different databases on different platforms. Currently, you can then either process them
remotely, which is a valid solution for infrequent processing and reasonable amounts of data,
or you need to move the data to the most suitable place for the overall processing.
IBM has been at the forefront of Data Management for a long time and is now starting to offer
solutions in the area of information integration. Information integration is a collection of
technologies comprising DBMS, Web services, replication, federated systems, warehouse
functions, programming interfaces, and data models into a common platform, which provides
an end-to-end solution for transparently managing the high volume and the diversity of today’s
enterprise data. A good description of the foundation for this effort, which is likely to greatly
reduce the need for moving data, is reported in a series of articles contained in the recent
issue of the IBM Systems Journal - Vol. 41, No. 4, 2002, G321-0147.
In this IBM Redbook we concentrate on the instances where DB2 data has to be moved, or
copied, sporadically or periodically, across different database instances and different
platforms.
Each member of the DB2 Family (DB2 UDB for z/OS, DB2 UDB for Linux, UNIX and
Windows, and DB2 for iSeries) supports several functions and utilities to move data across
and within platforms.
Starting in the year 2001, IBM has also been delivering new tools. They are new competitive
products, or function-rich new versions, which provide tool integration for your DB2 and IMS
installations. These tools will:
Maximize the availability of your systems
Keep your operating environment running at peak performance
Meet requirements for additional recovery and replication capabilities
Besides focussing on the database tools to complement your DB2 UDB for z/OS and IMS
database engines, IBM is now also providing tools for the distributed platforms by releasing
new tools and versions at a fast rate.
This book provides an overview of what is currently available for DB2 for z/OS and DB2 for
Linux, UNIX, and Windows in terms of functions, utilities, and tools. We also discuss in detail
the two latest functions and interesting functionalities in the area of moving data: the High
Performance Unload and the Cross Loader. The first one is a tool, the second one is a new
option of the Load utility.
In terms of permutations on moving data, we have considered the cases of moving data
within the same environment, mainframe or distributed, and across the two platforms.
DB2
z/OS
z/OS
z/OS
DB2 DB2
z/OS z/OS
z/OS z/OS
UNIX Windows
Distributed platform
1.0.2 Terminology
Throughout this redbook we have tried to be meaningful and consistent with the terminology
related to the DB2 Family of products, and the platforms where they run, but every
generalization and abbreviation tends to be arbitrary and sometimes wrong, so we
summarize here our definitions for reference purposes.
DB2 for z/OS means DB2 UDB for z/OS and OS/390. All our tests were at DB2 UDB for z/OS
and OS/390 Version 7 level.
DB2 distributed means DB2 UDB for Linux, UNIX, and Windows. Our tests were done with
DB2 UDB Version 7.2 and 8 on AIX and Windows. The term DB2 UDB is commonly used as
a way of differentiating DB2 distributed from DB2 for OS/390, but it is incorrect since DB2 for
OS/390 also became UDB with Version 6.
A few times multiplatform has been used interchangeably with distributed platform (like in the
name of products), while crossplatform has been used to include both the mainframe and the
distributed environments.
Chapter 1. Introduction 5
1.1 Contents of this redbook
These are the parts and chapters contained in this book:
Part 1: Introduction
We briefly discuss the different DB2 data movement functions and utilities in the first part
of this book. We then present an overview of the capabilities and functions of most IBM
tools available for this purpose.
Part 2: Product functions and utilities
In the second part, we analyze in more detail the functionalities of the DB2 subsystems
and related utilities. We present the advantages and disadvantages of the following
functions:
– Unload with DB2 for z/OS
– Load with DB2 for z/OS
– Export and Import with DB2 distributed
– Load with DB2 Distributed
Part 3: High Performance Unload
In this part we examine functions and performance of the recent new releases of the two
flavors of the IBM High Performance Unload tool:
– High Performance Unload for z/OS
– High Performance Unload for Multiplatforms
Part 4: Scenarios
In this part we consider how to become prepared to execute sample scenarios of moving
data within and across the host and distributed platforms:
– Getting ready for moving data
– Moving data to DB2 for z/OS
– Moving data to DB2 Distributed
DSN1COPY does not require DB2 authorization. However, usually the data set is protected
by Resource Access Control Facility (RACF); if so, you need sufficient RACF authorization.
For more details, see: DB2 UDB for OS/390 and z/OS V7 Utility Guide and Reference,
SC26-9945-03.
DSN1COPY should only be used when you need to access the data outside DB2 or you need
to do an OBID translation. All other needs can be solved with utilities and tools mentioned in
the following sections.
DSNTIAUL unloads some or all rows from up to 100 DB2 tables. With DSNTIAUL, you can
unload data of any DB2 built-in data type or distinct type. DSNTIAUL unloads the rows in a
form that is compatible with the Load utility and generates control statements for the Load
utility.
DSNTIAUL is written in assembler language and is shipped only as source code, so you must
precompile, assemble, link, and bind it before you can use it.
If you choose to specify the SQL parameter, your input must contain one or more complete
SQL statements. Each of them must end with a semi-colon. You can include any SQL select
statement that can be executed dynamically in your input data set.
If you do not specify the SQL parameter, your input data set must contain one or more
single-line statements (without a semi-colon) that use the following syntax:
table or view name [WHERE conditions] [ORDER BY columns]
Each input statement must be a valid SQL SELECT statement with the clause SELECT *
FROM omitted and with no ending semi-colon. DSNTIAUL generates a SELECT statement
by appending SELECT * FROM for each input statement. For this input format, the text for
each table specification can be a maximum of 72 bytes and must not span multiple lines.
For more details, see DB2 UDB for OS/390 and z/OS V7 Administration Guide,
SC26-9931-03, and DB2 UDB for OS/390 and z/OS Version 7 Application Programming and
SQL Guide, SC26-9933.
DSNTIAUL cannot unload data from an image copy, only from a table.
The SQL parameter gives you the possibility to include delimiters in the result set through
constants in the select list.
Currently, there are several alternatives to DSNTIAUL, each one with its characteristics
described in more detail in the corresponding sections:
DB2 Reorg utility with the UNLOAD EXTERNAL option provides faster unloading than the
DSNTIAUL, but it does not have the SQL option and it requires Reorg utility authorization.
DB2 Unload utility provides faster unloading than the DSNTIAUL, but it does not have the
SQL option. The authorization requires SELECT authorization, like DSNIAUL.
DB2 High Performance Unload tool provides performance similar to or better than the
Unload utility and SQL flexibility. It offers the DSNTIAUL format option on output. If you
want better performance than with your old DSNTIAUL solutions, you should consider this
tool.
This option results in a format usable by the Load utility. It also generates utility control
statements for the Load if requested.
With use of the WHEN clause you can also restrict the data being unloaded.
For more details, see DB2 UDB for OS/390 and z/OS V7 Utility Guide and Reference,
SC26-9945-03.
DB2 V7 offers a new utility, DB2 Unload, which can be considered a replacement to REORG
UNLOAD EXTERNAL. DB2 Unload provides faster unloading than the Reorg utility and only
the SELECT authorization is needed
Unload can be used to unload data from one or more source objects to one or more
sequential data sets in external formats. The sources can be:
DB2 table spaces
DB2 Image Copy data sets, including inline copies taken during Reorg and Load utility.
The table space of which the image copy is being unloaded must exist. Image Copies of
dropped table spaces cannot be used.
The Unload utility requires SELECT authorization on the table or tables in the table space.
For more details, see Chapter 3, “Unload with DB2 for z/OS” on page 33, and DB2 UDB for
OS/390 and z/OS V7 Utility Guide and Reference, SC26-9945-03. DB2 V7 offers new
possibilities. The recently announced DB2 for z/OS Version 8 offers the possibility of
unloading data into a delimited file. See DB2 UDB for z/OS Version 8 What's New?, available
from the Web site:
http://www.ibm.com/software/data/db2/os390/db2zosv8.html
For performance considerations see the Redbooks DB2 for z/OS and OS/390 Version 7 Using
the Utilities Suite, SG24-6289, and DB2 UDB for OS/390 and z/OS Performance Topics,
SG24-6129.
You should consider DB2 High Performance Unload tool as alternative to the DB2 Unload
utility:
Performance tests shows a slightly better performance than the Unload utility, and
considerable less CPU time in execution. To gain these figures it is an absolute condition
that it does not use the DB2 engine to perform the SQL.
It provides you with more versatility because you can use the SQL Select statement to
select the rows and columns that you want to be unloaded.
If you want to unload from an incremental image copy
It also provides you with more flexibility regarding customizing the output through the
USER DEFINED format.
The DELIMTED format is compatible with the DEL format on a distributed platform.
If you do not have the ownership of the table to be loaded, you need Load authorization on
the table. You also need SELECT authorization on the DB2 table or view if you are reading
the result set from. The recently announced DB2 for z/OS Version 8 offers the possibility of
loading data from a delimited file. See DB2 UDB for z/OS Version 8 What's New?, available
from the Web site:
http://www.ibm.com/software/data/db2/os390/db2zosv8.html
For more details, see Chapter 4, “Load with DB2 for z/OS” on page 51 and DB2 UDB for
OS/390 and z/OS V7 Utility Guide and Reference, SC26-9945-03.
In regards to the performance of loading, the Load utility is currently superior to all other
functions and tools.
Cross loading is done using the new DB2 V7 option INCURSOR in the DB2 Load utility. With
this option you tell the Load to read the data from the result set of a cursor instead of reading
it from an input sequential data set.
The data is read from the source location with a dynamic SQL statement (enclosed between
EXEC SQL and ENDEXEC statements) and loaded into a table at the target location by the
Load utility. The source data can be on the local system, on a remote DRDA server. The input
source can also be on any system accessible via a Federated Database (see Appendix A,
“Defining a Federated Database” on page 299.)
EXEC SQL is a new DB2 V7 utility statement that can be placed anywhere in the utility input
stream. It can be used for two purposes:
Executing a non-select dynamic SQL statement before, between or after the actual utility
statements
Declaring a cursor with a SQL select statement for use with the Load utility (Cross
Loader). The declare cursor produces a result set.
Note: EXEC SQL can simplify the JCL coding by eliminating dynamic SQL applications
like DSNTIAD or DSNTEP2 from the JCL stream. It can merge different utility steps,
separated by dynamic SQL applications, into one single utility step.
A typical Cross Loader example therefore consists of the definition of the dynamic SQL
statement via the EXEC SQL DECLARE CURSOR utility statement, followed by a LOAD
utility statement referring to this cursor. This is illustrated in Example 2-1 where we load an
existing summary table called EMPSUMMARY with data coming from the local sample table
DSN8710.EMP. The aggregation is done in the SQL statement of the CURSOR definition.
As you can see, it is a single job process that replaces the typical sequence of jobs of
unloading, file transfer, and loading the data, locally or remotely.
For more details, see Chapter 4, “Load with DB2 for z/OS” on page 51 and DB2 UDB for
OS/390 and z/OS V7 Utility Guide and Reference, SC26-9945-03.
The Cross Loader with its EXEC SQL statement, is a very flexible and handy function of the
Load utility. It combines the flexibility of the SQL statement and the performance of the Load
utility. The source can either be on the mainframe, in a distributed system, or in any system
accessible via a Federated Database.
With reference to moving data, the DB2 UDB Backup and Restore utilities greatly facilitate the
way to clone a table space or database within the same platform.
For details, see IBM DB2 UDB Command Reference Version 8, SC09-2951-01.
The Export utility exports data from a database to an operating system file or named pipe,
which can be in one of several external file formats. This file with the extracted data can be
moved to a different server.
The IXF file format results in an extract file consiting of both metadata and data. The source
table (including its indexes) can be recreated in the target environment if the CREATE mode
of the Import utility is specified. The recreation can only be done if the query supplied to the
Export utility is a simple SELECT *
The following is an IXF example of the export command specifying a message file and the
select statement:
export to stafftab.ixf of ixf messages expstaffmsgs.txt select * from staff
See Chapter 5., “Export and Import with DB2 distributed” on page 79 for restrictions that
apply to the Export utility. For details, see Chapter 1 of IBM DB2 UDB Data Movement Utilities
Guide and Reference, SC09-4830.
The Export utility can be used to unload data to a file or a named pipe from a table residing in
the following:
Distributed database
Mainframe database through DB2 Connect (only IXF format)
Nickname representing a remote source table (see Appendix A, “Defining a Federated
Database” on page 299, for details).
Note: If performance is an issue, the DEL format covers your needs, and all rows are to
be unloaded, then you should consider High Performance Unload tool for Multiplatforms.
See 2.4.6, “DB2 High Performance Unload tool for Multiplatforms” on page 26 for a brief
description. The tool must be executed from the machine where the source table
resides.
The db2batch command is used to monitor the performance characteristics and execution
duration of SQL statements. This utility also has a parallel export function in partitioned
database environments that:
Runs queries to define the data to be exported
On each partition, creates a file containing the exported data that resides on that partition
A query is ran in parallel on each partition to retrieve the data on that partition. In the case of
db2batch -p s, the original SELECT query is run in parallel. In the case of db2batch -p t
and db2batch -p d, a staging table is loaded with the export data, using the specified query,
and a SELECT * query is run on the staging table in parallel on each partition to export the
data. To export only the data that resides on a given partition, db2batch adds the predicate
NODENUMBER(colname) = CURRENT NODE to the WHERE clause of the query that is run
on that partition. The colname parameter must be set to the qualified or the unqualified name
of a table column. The first column name in the original query is used to set this parameter.
It is important to understand that db2batch runs an SQL query and sends the output to the
target file, it does not use the Export utility. The Export utility options are not applicable to
parallel export. You cannot export LOB columns using the db2batch command.
Run db2batch -h from the command window to see a complete description of command
options.
The db2batch command executes a parallel SQL query and sends the output to a specified
file. Note that the command is executing a select statement, not the Export utility. LOB
columns, regardless of data length, cannot be exported using this method.
In this example:
The query is ran in parallel on a single table (-p s option)
Connection is made to the sample database (-d sample option)
The control file staff.batch contains the SQL select statement (select * from staff)
Output is stored to staff.asc file, default output format is positional ASCII (remember that
db2batch is not using the Export utility)
Only the output of the query will be sent to the file (-q on option)
In this example:
Only non-LOB columns from emp_resume table are selected
(select empno,resume_format from emp_resume)
emp_resume.del file contains the query output in delimited ASCII format (-q del option),
, is the default column delimiter and | is the default char delimiter
emp_resume.out contains the query statistics
The following authorization is needed when using the Import utility to:
Create a new table you must at least have CREATETAB for the database
Replace data you must have SYSADM, DBADM or CONTROL
Append data you must have SELECT and INSERT
The following is an example of the IMPORT command issued through the CLP window:
import from stafftab.ixf of ixf insert messages impstaffmsgs.txt into userid.staff
Attention: When creating a table from an IXF file, not all attributes of the original table are
preserved. For example, referential constraints, foreign key definitions, and user-defined
data types are not retained.
See Chapter 5., “Export and Import with DB2 distributed” on page 79 for restrictions that
applies to the Import utility. For more details, see Chapter 2 of IBM DB2 UDB Data Movement
Utilities Guide and Reference, SC09-4830.
The import utility can be used to insert data from a file or a named pipe to a table in a
Distributed database
Mainframe database through DB2 Connect (only IXF format)
Note: For performance, use the Load utility on distributed wherever it is possible,
except for small amounts of data.
The following is an example of Load from a file. The command specifies a message file, that
tempfiles are to be used, the path, replace option, and the table to be loaded:
load from stafftab.ixf of ixf messages loastaff.msgs
tempfiles path /u/myuser replace into staff
Important: The Load utility does not fire triggers, and does not perform referential or table
constraints checking. It does validate the uniqueness of the indexes.
See Chapter 6, “Load with DB2 Distributed” on page 91 for restrictions that apply to the Load
utility. For more details, see Chapter 3 of IBM DB2 UDB Data Movement Utilities Guide and
Reference, SC09-4830.
The Load utility loads data from a file or a named pipe into a table a:
Local distributed database where the load runs
Remote distributed database through a locally cataloged version using the CLIENT option
The Load utility is faster than the Import utility, because it writes formatted pages directly into
the database, while the Import utility performs SQL INSERTs.
Attention: Data Propagator does not capture changes in data done through the Load
utility.
By specifying the CURSOR file type when using the Load utility, you can load the results of an
SQL query directly into a target table without creating an intermediate exported file.
To execute a load from cursor operation from the CLP, a cursor must first be declared against
an SQL query. Once this is done, you can issue the LOAD command using the declared
cursor’s name as the cursorname and CURSOR as the file type. The following CLP
commands will load all the data from your.TABLE1 into my.TABLE1:
DECLARE mycurs CURSOR FOR SELECT * FROM your.table1
LOAD FROM mycurs OF cursor INSERT INTO my.table1
See Chapter 5., “Export and Import with DB2 distributed” on page 79 for restrictions that
apply to the Import utility. For more details, see Chapter 3 of the IBM DB2 UDB Data
Movement Utilities Guide and Reference, SC09-4830.
The target table has to be in the same database as the source table or the source nickname.
This is a very flexible way of moving data within the distributed platforms.
The tool queries the system catalog tables for a particular database and compiles a list of all
user tables. It then exports these tables in IXF format. The IXF files can be imported or loaded
to another local DB2 database on the same system, or can be transferred to another platform
and imported or loaded into a DB2 database on that platform.
This tool calls the DB2 Export, Import, and Load APIs, depending on the action requested by
the user. Therefore, the requesting user ID must have the correct authorization required by
those APIs, or the request will fail.
This tool exports, imports, or loads user-created tables. If a database is to be duplicated from
one operating system to another operating system, db2move facilitates the movement of the
tables. It is also necessary to move all other objects associated with the tables, such as:
aliases, views, triggers, user-defined functions, and so on.
The load action must be run locally on the machine where the database and the data file
reside. A full database backup, or a table space backup, is required to take the table space
out of backup pending state.
For details about the Export, Import and the Load utility, see:
Chapter 5, “Export and Import with DB2 distributed” on page 79
Chapter 6, “Load with DB2 Distributed” on page 91
For details about the db2move command; see IBM DB2 Universal Database Command
Reference, SC09-2951-01.
DB2 UDB db2move is a common command and option interface to invoke the three utilities
mentioned above.
db2look can also generate update statement for the catalog statistics and the configuration
parameters for the system.
This tool can also generate the required UPDATE statements to replicate the statistics on the
objects in a test database, as well as statements for the update of the database configuration
and database manager configuration parameters.
To execute these commands you need SELECT authorization on the system catalogs.
For details, see Chapter 9, “Getting ready for moving data” on page 213, and IBM DB2
Universal Database Command Reference, SC09-2951-01.
db2look is not a tool for moving data, but we highly recommend it for moving complete or
partial data definitions when this is needed.
The DB2 Admin ALTER and MIGRATE functions can simplify administration tasks. After using
the ALTER function to specify desired changes, the tool generates the jobs required to
implement these changes. These jobs unload the data, recreate the table, and reload the
data. The tool handles all object dependencies during ALTER and MIGRATE. And, after the
MIGRATE function has defined the target DB2 subsystem, DB2 Admin creates the jobs
needed to copy definitions and data to the target:
The ALTER function lets you change the name and attributes of a table or column, insert
new columns, and drop existing columns. The ALTER of primary key characteristics can
be propagated to foreign keys.
The MIGRATE function facilitates the copying of all the objects and data in one or more
databases or table spaces to another DB2 subsystem.
Prompt options can be activated for five types of statements: definition, authorization, and
update SQL, DB2 commands, and DSN commands. These options enable you to edit or
execute the statements, put them in work statements or run them in batch jobs.
When dealing with the need to move DB2 data, the MIGRATE function of the DB2 Admin tool
facilitates the copying of all the object definitions and data in one or more databases or table
spaces to the same or another DB2 subsystem. Admin’s cloning capability allows one to
extract the DDL (and data) from a source DB2 system, move the definitions to a target
system, and change the DB2 identifiers (such as owner, name, or dbname) tailoring them to
the naming standards of the target system.
For instance, you can use MIG to copy a whole DB2 database. Migrate is done in three steps:
1. Fill in the migrate panels to generate jobs.
2. Run jobs on source system.
3. Run jobs on target system.
For the general use of panels and for migration examples, see DB2 for z/OS DM Tools for
Database Administration and Change Management, SG24-6420-00.
When using the MIGrate command, you can use the ADD command to add new database, or
tables from another database, to be migrated at the same time. You can change the database
name, as well as the owner and storage group for indexes and table spaces. You can choose
whether you want to migrate only the DDL, the data, or both.
If you are dealing with several databases and several objects, make sure to have PTF
UQ72062 for APAR PQ68028 applied. It provides enhancements to MIGRATE by allowing the
creation of work statement lists, the cloning of these statements, and the masking of names.
MIGRATE generates jobs to perform the requested tasks. It can drop the existing target
database at your request, as image copies and run check data and runstats. When the target
database is in the same subsystem as the source database, you can submit the jobs locally.
For more details on using MIGRATE locally or remotely, see DB2 Administration Tool for z/OS
User's Guide, SC27-1601-02.
We have used this tool for the task of generating DDL, see Chapter 9, “Getting ready for
moving data” on page 213.
DB2 Data Export Facility provides an interface for extracting data based either on referential
structures defined in DB2 or on a simple table.
When operating on referential structures you can start anywhere in a referential set and
navigate anywhere throughout the set. The tool allows easy selection of the desired scope of
data among the referential set. This can be a table, a table and all its dependencies, or only
certain dependencies.The result will be referentially intact sets of data.
When you tell DEF that you want to export data it will build a file with SQL in it to extract the
data. The extracted data is placed in a file (or files). The data is written to these files in a
format that could be used as input to the DB2 Load utility. It also optionally builds the LOAD
control card for each table in the RI set. It generates a job to do all of this.
Note: DB2 Data Export Facility does not create the DDL for the target subsystem. You
must use another product such as DB2 Automation tool to prepare the target environment
to receive the data exported by DB2 Data Export Facility.
For details, see DB2 Data Export Facility for z/OS User’s Guide, SC27-1466-00.
The basic part of HPU is an UNLOAD command and an optional SELECT statement,
compatible with the syntax of the DB2 SELECT statement.
Partitioned table spaces can be unloaded in parallel by partition to multiple output files.
HPU can:
Do multiple unloads of the same table space or image copy
Help you to manage and control the unload activity
Work outside DB2 and access the:
– VSAM files that contain the table space
– Sequential files that contains the image copy data set
HPU scans a table space and creates the output file in the format you specify. The output
format can be:
DSNTIAUL compatible
VARIABLE, variable length records
DELIMITED, a delimited file
USER, choice free conversion of the output
Note: The translation from EBCDIC to ASCII and from ASCII to EBCDIC is supported via
the translation values provided in SYSIBM.SYSSTRINGS table.
HPU can also be used either in batch or interactive mode via panels from the DB2
Administration tool.
For details, see Chapter 7, “IBM DB2 High Performance Unload for z/OS” on page 119, and
IBM DB2 High Performance Unload for z/OS Version 2, Release 1 User’s Guide,
SC27-1602-00.
DB2 High Performance Unload tool is a valid alternative to the DB2 Unload utility:
Performance tests shows a slightly better performance than the Unload utility and a
considerable less CPU time in execution. To gain this performance advantage it is
necessary to use the native HPU, that is it should be executed without using the standard
SQL via the DB2 engine.
HPU provides you with more versatility than Unload because you can use the SQL select
statement to select the rows and columns that you want to be unloaded.
HPU can unload from an incremental image copy.
HPU also provides you with more flexibility regarding customizing the output through the
USER DEFINED format.
The DELIMTED format of HPU is compatible with the DEL format on distributed platform
For recent technical information on HPU, and also comparisons with Unload, specify High
Performance Unload in the search field at the Web site:
http://www.ibm.com/support/search
Note: Data can also be replicated from non-IBM relational database management systems
by use of a Federated Database.
The tool replicates changes in data across the enterprise motivated by the need of:
Distributing data to other systems or locations
Consolidating data from other systems or locations
Auditing changes to sensitive data
Data Propagator has a set of control tables with information about which source tables to
capture changes from; information about subscribers on changes; and where to deliver the
changes is also needed. Status about capturing and delivering is continuously updated.
The Replication Center can be used to do this. The Replication Center is a graphical interface
that runs on Windows and UNIX systems and it must have connectivity to both the source and
the target servers.
For details, see IBM DB2 Replication Guide and Reference, SC26-9920-00, and the recent
redbook A Practical Guide to DB2 UDB Data Replication V8, SG24-6828.
If you need to move data on a regular basis, Data Propagator is a very efficient tool whenever
you are updating the target with only the changes to the source. This reduces processing and
transmission. Data Propagator administers the process and the schedules of the job runs.
Compared to other function and tools, Data Propagator is not suitable for a one time only data
movement. It is a tool that helps you keeping your databases in sync continuously or making
captured changes available. To facilitate this, a substantial preparation and customizing effort
is necessary.
DB2 Web Query tool uses Java technology to provide server platform independence, and it is
running in a Java servlet application server environment.
DB2 Web Query tool allows you to run SQL queries against DB2 databases and view the
results, or export them for use in other applications, such as:
Create and run SQL queries
Save queries and results for later use
View query results through your web browser
E-mail query results
Export query results to a new or existing table
Export query results to the following formats:
– XML
– HTML
– CSV (comma separated value)
– text files
– Microsoft Excel
Connect to Informix Version 9.3 databases
For details, see IBM DB2 Web Query Tool User’s Guide, SC27-0971-05, and the recent
redbook DB2 Web Query Tool Version 1.2, SG24-6832.
Note: The DB2 Web Query tool is product that can access DB2 data on z/OS, distributed
platforms, and iSeries.
You can unload larger volumes of data than the operating system file system limit through
unloading into several smaller output files.
HPU creates messages that contain detailed summaries of unload operations, including
unload process statistics, results, and error descriptions.
The following examples show how to invoke HPU with the use of a control file containing the
unload instructions for two situations:
db2hpu -f sampleN.cntl
The sample1.ctl control file unloads a table:
GLOBAL CONNECT TO SAMPLE;
UNLOAD TABLESPACE SAMPLE.USERSPACE1
SELECT *FROM Administrator.EMPLOYEE;
OUTPUT("c:\gasample \sample01.out");
The sample2.ctl control file unloads a table space from a backup:
GLOBAL CONNECT TO SAMPLE;
UNLOAD TABLESPACE USERSPACE1
backup "C:\TEMP \SAMPLE.0 \DB2 \NODE0000 \CATN0000 \20020715 \133912.001"
OUTPUT ("c:\gasample \sample2.out"REPLACE)FORMAT DEL;
For details, see Chapter 8, “IBM DB2 High Performance Unload for Multiplatforms” on
page 193, and IBM DB2 High Performance Unload for Multiplatforms User’s Guide,
SC27-1623-01.
When HPU does not access the data via the DB2 engine, it is significantly faster than the DB2
EXPORT utility.
However, the use of the DB2 Export utility is recommended in the following cases:
When you are doing selections on rows (WHERE conditions.)
When you need to run a SELECT statement that HPU does not support, which includes
SELECT statements that contain joins of multiple DB2 tables, recursive queries, or views.
When the SELECT statement you are running could use an index (HPU does not use all
indexes to access data in the table that you want to unload.)
When you need to unload a table in a single-partition environment that is not physically
located on the machine where HPU is running.
You can use the DWC to define the structure of the operational databases, called sources.
You can then specify how the operational data is to be moved and transformed for the
warehouse. You can model the structure of the tables in the warehouse database, called
targets, or build the tables automatically as part of the process of defining the data movement
operations. The DWC uses the following DB2 functions to move data:
SQL to select data from sources and insert the data into targets.
DB2 utilities to export data from a source and then use DB2 Load the target
Replication to copy large quantities of data from
See the Data Warehouse Center Administration Guide, SC26-9993-01, and also DB2
Warehouse Management: High Availability and Problem Determination Guide, SG24-6544.
We have not used this tool during this project.
DSN1COPY M 2.2.1 X X
DSNTIAUL M 2.2.2 X X
Warehouse D 2.4.7 X X X X
Manager
Load and Unload utilities for DB2 for z/OS and OS/390 Version 7 are made available through
the DB2 Version 7 Utilities Suite.
We show you:
A brief overview of the Unload utility
The advantages it has over its predecessors
Syntax and rules in using the Unload
The possible options when using Unload
Some examples on using the Unload utility
Unload can be used to unload data from one or more source objects to one or more BSAM
sequential data sets in external formats. The source can be DB2 table spaces, DB2 Image
Copy data sets.
The online functions of Unload allow the unload of data from DB2 tables with SHRLEVEL
CHANGE, which enhances the continuous availability of DB2 subsystems.
The Unload utility requires SELECT authority on the table or tables in the table space. This is
similar to the DSNTIAUL unload programs, but differs from REORG UNLOAD EXTERNAL,
which requires REORG utility authority.
The DISCARD option of REORG UNLOAD EXTERNAL, which can be used to discard data
with the WHEN clause, is not supported in the Unload utility.
With the current versions of DB2, you cannot load a delimited input file into DB2. A delimited
file is a sequential file that contains row and column delimiters often used to move data
across the distributed platforms. With the recently announced DB2 for z/OS Version 8, you
will be able to use the Load utility to load into DB2 a delimited input file from another relational
database. Even more important, you will not need to write a program that converts the data
into the correct format, or use INSERT processing and give up the performance advantages
of the Load utility. See the following Web site for more information on DB2 for z/OS Version 8:
http://www.ibm.com/software/data/db2/os390/db2zosv8.html
created by:
COPY
table copy MERGECOPY
space data set DSN1COPY
FROM TABLE selection
Row selection SHRLEVEL REFERENCE / CHANGE
External format Sampling, limitation of rows
numeric General conversion options:
date / time encoding scheme, format
Formatting Field list:
NOPAD for VARCHAR selecting, ordering, positioning, formatting
length, null field
single
data set data set
Partition parallelism
forset
data part1
for part2
Unloading records to
sequential data sets.
If UNLOAD is processing
a table or partition, DB2
UNLOAD takes internal commits to
provide commit points at
which to restart in case of
operation should halt in
this phase
UTILTERM
Clean-up
Sequential Sequential dataset
dataset is written as output
Image copy created by concurrent copy is not supported by Unload. Unloading data from
image copy is not supported by REORG UNLOAD EXTERNAL utility and the DSNTIAUL
program.
Note: The table space of the image copy must exist in the host DB2 subsystem for
unloading from copy data sets. Copies of dropped table spaces are not supported.
The syntax for the Unload utility from image copy is shown in Figure 3-3. Here are some
additional considerations when using the FROMCOPY option:
Only a single copy data set name can be specified using the FROMCOPY option. Use
FROMCOPYDDN if multiple image copies are concatenated to a DD statement.
The table space must exist when Unload is run.
The table space should not have been dropped and recreated since the image copy was
taken (unless the OBID has been kept identical).
If the table was altered with ALTER ADD COLUMN after the image copy was taken,
Unload will set system or user defined defaults for the added column when the data is
unloaded from such an image copy.
Image copy created by Inline COPY operation (LOAD or REORG TABLESPACE) can
contain duplicate pages. If duplicate pages exist, the Unload utility issues a warning
message, and all the qualified rows in the duplicate pages will be unloaded into the output
data set.
If incremental copy is specified as the source, only the rows in the data set are unloaded.
Note: TEMPLATE can be used for the SYSPUNCH and SYSREC data set definitions
identified as PUNCHDDN and UNLDDN options in the UNLOAD syntax respectively.
LISTDEF cannot be used to pass a list to the LIST option to specify image copy data
sets.
source-spec:
TABLESPACE db-name.ts-name
ts-name PART integer
int1:int2
FROMCOPY data-set-name
FROMVOLUME CATALOG
vol-ser
FROMCOPYDDN dd-name
unload-spec:
PUNCHDDN SYSPUNCH UNLDDN SYSREC
The contents of the data set associated with PUNCHDDN (SYSPUNCH) is displayed in
Example 3-2. If the space allocation is not specified in the TEMPLATE statement (refer back
to Example 3-1), then DB2 calculates the space requirements using the formulas:
SYSPUNCH = ((#tables * 10) + (#cols * 2)) * 80 bytes
SYSREC = ((high used RBA) + (#records * (12 + length of longest clustering key)) bytes
A further filter on the volume of unloaded data can be achieved with the SAMPLE option.
SAMPLE indicates the percentage of data to be unloaded. If the WHEN clause is used to
unload selective rows, then SAMPLE is applied only on rows qualified by the WHEN selection
condition.
Note: The sampling is applied per individual table. If the rows from multiple tables are
unloaded with sampling enabled, the referential integrity between the tables might be lost
If the image copy is an incremental copy, or a copy of a partition or partitions, then the
compression dictionary pages must exist in the same data set, otherwise Unload will fail and
DB2 will issue an error message.
Not supported:
Separate output data sets per partition
Concurrent copies
Copies of dropped tables
Copy data sets of multiple table spaces
Unload of LOB columns
When unloading multiple table spaces with a LISTDEF, you must also define a data set
TEMPLATE that corresponds to all the table spaces and specify the template-name in the
UNLDDN option.
Restrictions
Index spaces, LOB table spaces and directory objects must not be included in the LISTDEF
definition. The FROM TABLE-spec of Unload is not supported with the LIST option.
Note: Unloading from a list of table spaces is fully supported by REORG UNLOAD
EXTERNAL.
UNLOAD does not activate parallel unloads if only a single output data set is allocated to
each table space even though the PART or PARTLEVEL option is coded in the UNLOAD
utility statement or LISTDEF command respectively. TEMPLATE can be used to dynamically
allocate an output data set per partition by using the &PA key word.
Example 3-5 Sample Unload job for partition table space and parallelism
TEMPLATE ULDDDN
DSN(DB2V710G.RAMA.&TS..P&PA..UNLOAD)
UNIT(SYSDA) CYL DISP(NEW,CATLG,DELETE)
VOLUMES(SBOX57,SBOX60)
TEMPLATE PNHDDN
DSN(DB2V710G.RAMA.&TS..PUNCH)
UNIT(SYSDA) CYL DISP(NEW,CATLG,DELETE)
VOLUMES(SBOX57,SBOX60)
LISTDEF UNLIST
INCLUDE TABLESPACE U7G01T11.TS* PARTLEVEL
UNLOAD LIST UNLIST
PUNCHDDN PNHDDN UNLDDN ULDDDN
In Example 3-5 we unloaded a list of table spaces using the LISTDEF wildcard specification
and PARTLEVEL. We also allocated the output data sets using TEMPLATE with &PA in the
DSN definitions. It can be seen in the output of Example 3-6 that DB2 has used two parallel
tasks to unload the data by partition. UNLOAD has also created three data sets via
TEMPLATE definitions as output data sets, one for each partition. If the &PA key word was not
allocated to the DSN of TEMPLATE ULDDDN, then DB2 would have allocated only a single
output data set, and the unload of data from partitions would be done in sequence.
Example 3-6 Sample Unload output by partition and parallelism
DSNU000I DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = UNLOAD
DSNU050I DSNUGUTC - TEMPLATE ULDDDN DSN(DB2V710G.RAMA.&TS..P&PA..UNLOAD) UNIT(SYSDA)
CYL DISP(NEW,CATLG,DELETE)
VOLUMES(SBOX57,SBOX60)
DSNU1035I DSNUJTDR - TEMPLATE STATEMENT PROCESSED SUCCESSFULLY
SHRLEVEL CHANGE
SHRLEVEL CHANGE allows users to update the tables in the table space while data is being
unloaded. When data is fetched from the table space with ISOLATION CS, the Unload utility
assumes CURRENTDATA(NO). This ensures that uncommitted data is not unloaded and
retains data currency. Data can also be unloaded with ISOLATION UR, where any
uncommitted data will be unloaded. No locks are taken on the objects; this allows other DB2
operations to continue on the objects from which the data is being unloaded.
SHRLEVEL REFERENCE
This operation allows users to read the data during the unload. All writers are drained from
the table space before commencement of the unload. When data is unloaded from multiple
partitions, the drain lock will be obtained for all of the selected partitions in the UTILINIT
phase.
In Example 3-7 we also show the usage of the WHEN option with selection criteria.
Each WHEN option applies to the FROM TABLE option only. Here we unload rows from
SYSTABLEPART, SYSTABLES and SYSTABLESPACE where the WHEN option explicitly
qualifies the data selection criteria for each table respectively.
Note: If the rows from multiple tables are unloaded with sampling enabled, the referential
integrity between the tables may be lost.
The LIMIT option can be used to limit the total number of records unloaded from a table. If the
number of unloaded rows reaches the specified limit, message DSNU1202 is issued for the
table, and no more rows are unloaded from the table. The process continues to unload
qualified rows from the other tables.
When partition parallelism is activated, the LIMIT option is applied to each partition instead of
the entire table.
Note: If multiple tables are unloaded from with the LIMIT option, the referential integrity
between the tables may be lost.
Example 3-7 Unload selective tables from SYSDBASE using FROM TABLE
//STEP1 EXEC DSNUPROC,SYSTEM=DB2G,UID=UNLOAD,
// UTSTATS=''
//SYSIN DD *
The job outputs two data sets that contain the SYSPUNCH and SYSREC information.
DB2V710G.RAMA.SYSDBASE.PUNCH
DB2V710G.RAMA.SYSDBASE.UNLOAD
If the length parameter is omitted, the default is the smaller of 255 and the maximum length
defined on the source table column.
For a complete list and description of column functions on data types, please refer to Chapter
29 of DB2 UDB for OS/390 and z/OS V7 Utility Guide and Reference, SC26-9945-00.
Tables can also be created with the European English character set of 1140 (Euro support) by
changing the CCSID EBCDIC to CCSID 1140.
All character type data can be converted from the host internal code, predominantly from
EBCDIC to other data types, such as ASCII and UNICODE on the S/390 DB2 databases. The
UNLOAD statement in Example 3-9 converts all the character fields on table REGION into
ASCII.
The alternate way to convert to ASCII is to use the CCSID option in the UNLOAD, as follows:
UNLOAD TABLESPACE U7G01T11.TSREGION PUNCHDDN PNHDDN UNLDDN ULDDDN
CCSID(01252,00000,00000)
In Example 3-10, table PART in table space TSPART was created with CCSID 1140, Euro
English code page. The table space TSPART was unloaded and CCSID was converted to
UNICODE. Unload converted all character data from CCSID 1140 to 367.
Note: Unload utilizes OS/390 services for CCSID conversion from 1140 to 367. There is no direct
translation from 1140 to 367. Please refer to DB2 for z/OS and OS/390 Version 7 Using the Utilities
Suite, SG24-6289 for examples of generating the translation table and installation of OS/390
UNICODE support.
Restrictions
Unload is not supported for table spaces in DSNDB01.
The FROM TABLE option cannot be used when the LIST option is already specified.
The following table spaces and image copy source objects are not supported:
– Auxiliary (LOB) table spaces
– Index spaces
– Dropped tables
– Views
– Global temporary tables
Restarting Unload
When restarting a terminated Unload utility, the following occurs:
Processing starts with the table spaces or partitions that had not yet been completed.
For a table space or partitions that were being processed at termination, Unload resets the
output data sets and processes those table spaces or partitions again.
When the source is one or more image copy data sets (FROMCOPY or
FROMCOPYDDN), Unload always starts processing from the beginning.
Note: Verify that the PTF for APAR PQ50223 is applied to avoid a problem generated
when a partitioned table space with PARTLEVEL in LISTDEF is unloaded with the
Unload utility and loaded with the Load utility.
With the current versions of DB2, you cannot Unload DB2 data into a delimited input file. A
delimited file is a sequential file that contains row and column delimiters often used to move
data across the distributed platforms. With the recently announced DB2 for z/OS Version 8,
you will be able to use the Unload utility to unload DB2 data to one or more delimited output
files. You can then load the data into another DB2 database in a z/OS environment or a
distributed platform, or import the data into an application in another relational database. See
the following Web site for more information on DB2 for z/OS Version 8:
http://www.ibm.com/software/data/db2/os390/db2zosv8.html
Table 4-1 summarizes the data sets used by the Load utility.
Input data set (INDD) The input data set containing Yes
the data to be loaded. It must be
a sequential data set readable
by BSAM.
Sort data sets These are temporary work data Yes (required if referential
(SYSUT1) sets needed for the sort input constraints exist and
(SORTOUT) and sort output. Their DD name ENFORCE (CONSTRAINTS) is
is specified by the WORKDD specified
option. The default DD name for or
the input is: if the table has indexes.)
SYSUT1 for the input and
SORTOUT for the output.
Mapping data set Work data set for mapping the Yes (required if referential
identifier of a table row back to constraints exist and
the input record that caused an ENFORCE (CONSTRAINTS) is
error. The default DD name is specified
SYSMAP. or
when you request discard
processing in loading tables
with unique index.)
Discard data set A work data set to hold copies Yes (required if requested
of records not loaded. It must through the Discard options of
be a sequential data set that is the utility control statement.)
readable by BSAM. Its DD or
template name is specified with
the DISCARDDN option of the
utility control statement. If you
omit this, Load creates the data
set with the same record
format, record length, and block
size as the input data set. The
default DD name is SYSDISC.
For more information please refer to Chapter 2 of the DB2 UDB for OS/390 and z/OS V7
Utility Guide and Reference, SC26-9945-03.
Example 2
Example 4-2 specifies dynamic allocation of the required data sets by DFSORT, using the
SORTDEVT and SORTNUM keywords. If sufficient virtual storage resources are available,
one utility subtask pair will be started to build each index. This example does not require
UTPRINnn DD statements, because it uses DSNUPROC to invoke utility processing, which
includes a DD statement that allocates UTPRINT to SYSOUT. See Example 4-2.
Example 3
Example 4-3 shows how to load selected columns into a non-empty table space. The input
sequential data file is in SYSREC DD.
For each source record that has LKA in its first three positions:
The characters in positions 7 through 9 are loaded into the DEPTNO column.
The characters in positions 10 through 35 are loaded into the DEPTNAME VARCHAR
column.
The characters in positions 36 through 41 are loaded into the MGRNO column.
Characters in positions 42 through 44 are loaded into the ADMRDEPT column.
Example 4
Example 4-4 shows how to load data into table PAOLOR7.DEPT from the data set specified
by the DEPTDS DD statement.
Example 5
Example 4-5 shows how to load data into two tables. Load data from the data set specified by
the DEPTDS DD statement into the PAOLOR7.DEPT and SANCHEZ.TESTDEPT tables.
Example 6
Example 4-6 shows how to load ASCII input data. Use the ASCII option to load ASCII input
data into a table named DEPT that was created with the CCSID ASCII clause.
The CCSID keyword is not specified in this example; therefore, the CCSIDs of the ASCII input
data are assumed to be the ASCII CCSIDs specified at installation. Conversions are done
only if the CCSIDs of the target table differ from the ASCII CCSIDs specified at installation.
Example 7
Example 4-7 shows how to load selected records into a table. Load data from the data set
specified by the DEPTDS DD statement into the TESTDEPT table. Load only from source
input records that begin with LKA.
LOAD SELECT
LOCAL DB2,
DRDA, or
Data Federated
Conversion Data DB2 family
Oracle
Sybase
Informix
IMS
VSAM
DB2 for SQL Server
OS/390 NCR Teradata
and z/OS
The data is read from the source location with a dynamic SQL statement and loaded in a
table at the target location by the Load utility. It is a single job process that replaces the typical
sequence of jobs of unloading, file transfer, and loading the data. The source data can be on
the local system or on a remote DRDA server.
Note: The source can be on any system accessible via a Federated Database, however
this book will focus only on the DB2 Family.
A typical Cross Loader example consists of the definition of the dynamic SQL statement via
the EXEC SQL DECLARE CURSOR utility statement, followed by a Load utility statement
referring to this cursor. This is illustrated in Example 4-8. In this example we load an existing
PAOLOR2.DEPT table with data from the local sample PAOLOR7.DEPT.
Example 4-8 Introductory Cross Loader example
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT *
FROM PAOLOR7.DEPT
ENDEXEC
LOAD DATA
INCURSOR C1
EXEC SQL is a new DB2 V7 utility statement explained in more detail in 4.2.2, “EXEC SQL
utility control statement” on page 59.
INCURSOR is a new DB2 V7 LOAD option explained in more detail in 4.2.1, “INCURSOR
Load option” on page 59.
Important: The Cross Loader was introduced in DB2 V7 after GA with PTF UQ55541 for
APAR PQ45268 and PTF UQ55542 for APAR PQ46759. Therefore, you should check if
these PTFs, and all their prerequisites, are applied to your DB2 system before trying to use
the Cross Loader.
The Cross Loader is being made available to all members of the DB2 Family. Once
implemented it allows the source data to reside on any remote system that can act as a
DRDA server.
To match the column names in the table being loaded, you can use the AS clause in the
select list to change the columns names returned by the SELECT statement.
You can only put one SQL statement between the EXEC SQL and ENDEXEC keywords. The
SQL statement can be any dynamic SQL statement that can be used as input for the
EXECUTE IMMEDIATE statement:
CREATE, ALTER, DROP a DB2 object
RENAME a DB2 table
COMMENT ON, LABEL ON a DB2 table, view, or column
GRANT, REVOKE a DB2 authority
DELETE, INSERT, UPDATE SQL operation
LOCK TABLE operation
EXPLAIN a SQL statement
SET CURRENT register
COMMIT, ROLLBACK operation
(see “Thread behavior and commit scope of the EXEC SQL utility statement” on page 62)
In Example 4-9 we create a new table in the default database DSNDB04 with the same layout
as PAOLOR7.DEPT.
Example 4-9 Creating a new table using LIKE
EXEC SQL
CREATE TABLE PAOLOR2.DEPT LIKE PAOLOR7.DEPT
ENDEXEC
In Example 4-10 we give this table a comment and allow everybody read access. Note the
two separate steps.
Example 4-10 Comment and grant in two separate EXEC SQL steps
EXEC SQL
COMMENT ON TABLE PAOLOR2.DEPT IS 'Copy of Paolor7 DEPT'
ENDEXEC
EXEC SQL
GRANT SELECT ON PAOLOR2.SYSTABLES TO PUBLIC
ENDEXEC
In the same way, we are able to create indexes on this table, create views on it, and so on. All
this is done in the utility input stream.
In Example 4-11 we declare a cursor for extracting rows with ADMRDEPT = ‘A00’ from
PAOLOR7.DEPT.
Example 4-11 Declare a cursor for the Cross Loader
EXEC SQL
DECLARE C1 CURSOR FOR
In Example 4-12 we show how this cursor can now be used in a LOAD statement (Cross
Loader.)
Example 4-12 Usage of a cursor in the LOAD statement
LOAD DATA
INCURSOR C1
INTO TABLE PAOLOR2.DEPT
The SQL statement in the declare cursor definition can be any valid SQL statement including
joins, unions, data conversions, aggregations, special registers, and UDFs. The source data
can be on a local server or remote server using DRDA access. See 4.2.3, “Using the Cross
Loader” on page 65 for more details.
The SQL statement placed after the EXEC SQL keyword is parsed and checked for errors
during its execution. It is not checked during the UTILINIT phase of the utility. If an invalid SQL
statement is found during the execution of the EXEC SQL, the utility job immediately ends
with return code 8. If the SQL statement is valid, but fails during execution (with a negative
SQL code), the utility also immediately ends with return code 8 as well. So be aware that if
you have syntax errors in an EXEC SQL statement and the utility job gets started, the
previous EXEC SQL statements and utility statements are already executed before the utility
ends. You might have to remove these from the input stream before rerunning the job.
Normally, a utility that encounters an SQL error during the EXEC SQL statement execution
always ends with return code 8 and never abends with ABEND04E. So the utility is not in a
stopped state; the utility is not restartable with the RESTART option and a TERMINATE
UTILITY command is NOT necessary. But be aware that all previous EXEC SQL and utility
statements are executed successfully and might have to be removed first before rerunning the
job.
Currently, it is impossible to influence the behavior of the utility job after a failing EXEC SQL
statement. The OPTION to allow to discard the failing EXEC SQL, and to continue the utility
step when the EXEC SQL failed, is currently not available in DB2 V7.
If the utility input stream contains both EXEC SQL statements and other utility statements,
and a utility statement failed so that DB2 put the utility in the stopped state, the utility step is
restartable with the RESTART keyword. During restart, all the non-select dynamic SQL
statements from EXEC SQL statements already executed, are skipped, except the ones with
SQL SET statements. All the declare cursor definitions within EXEC SQL statements already
executed, are reactivated so that they can be used in the following LOAD statements.
This can be illustrated with Example 4-13. This job contains one non-select dynamic SQL
statement (CREATE TABLE), one cursor definition, and one utility LOAD statement. If the
CREATE TABLE fails with a negative SQL code, the utility will immediately end with return
code 8 and the utility will not be restartable with the RESTART keyword. If the CREATE
TABLE executes successfully, but the DECLARE CURSOR fails, the utility will also end with
return code 8, but the table will have been created. If both CREATE TABLE and DECLARE
Thread behavior and commit scope of the EXEC SQL utility statement
The EXEC SQL statement runs in a thread that is separate from the utility thread. This implies
that the EXEC SQL SET CURRENT register operations do influence all following EXEC SQL
statements in the utility stream input, but they do not influence the real utility statements like
LOAD, REORG, and so on.
We can illustrate this with the utility job in Example 4-14. This job runs with USER=PAOLOR2.
So, the DB2 primary AUTHID is PAOLOR2. We change the current SQLID with EXEC SQL to
PAOLOR7 and try to see what table creator is used if we do not prefix our tables in the
following EXEC SQL statements and other utility statements. We only want to load the 100
most recently created tables. In V7 we can do this using the new SQL fetch-first-clause.
Example 4-14 JCL for testing the thread behavior of EXEC SQL
//PAOLOR2A JOB (ACCOUNT),'PAOLOR2',NOTIFY=PAOLOR2,USER=PAOLOR2
//*
// EXEC PGM=DSNUTILB,PARM='DB2G,CRLOAD'
//STEPLIB DD DSN=DSN710.SDSNLOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
EXEC SQL
SET CURRENT SQLID = 'PAOLOR7'
ENDEXEC
EXEC SQL
CREATE TABLE MYTABLE LIKE SYSIBM.SYSTABLES
ENDEXEC
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT * FROM SYSIBM.SYSTABLES
WHERE TYPE = 'T'
ORDER BY CREATEDTS DESC
FETCH FIRST 100 ROWS ONLY
ENDEXEC
LOAD DATA
INCURSOR C1
INTO TABLE PAOLOR7.MYTABLE
LOAD DATA RESUME(YES)
INCURSOR C1
INTO TABLE MYTABLE
Each block of EXEC SQL and ENDEXEC is a separate unit-of-work. Each block can only
contain a single SQL statement. The unit-of-work is always committed when the SQL
statement is executed successfully. Although the COMMIT and ROLLBACK statements are
accepted, these statements do not perform any function.
So, it is impossible to create your own unit-of-work consisting of multiple EXEC SQL
statements, and end that unit-of-work with EXEC SQL COMMIT ENDEXEC. It is also
impossible to have an EXEC SQL statement executed and undo its work by a following EXEC
SQL ROLLBACK ENDEXEC command.
We verified the above behavior with the utility job shown in Example 4-16. In the first EXEC
SQL we create a new table. This is followed by an EXEC SQL ROLLBACK to try to undo the
CREATE statement. In the third EXEC SQL we populate this table with an INSERT statement
and try to undo the INSERT in the fourth EXEC SQL. If the ROLLBACK statement in the
second EXEC SQL would undo the CREATE, we expect the third EXEC SQL to fail.
Example 4-16 JCL for verifying the commit scope of EXEC SQL
//PAOLOR2A JOB (ACCOUNT),'PAOLOR2',NOTIFY=PAOLOR2,USER=PAOLOR2
// EXEC PGM=DSNUTILB,PARM='DB2G,CRLOAD'
//STEPLIB DD DSN=DSN710.SDSNLOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
EXEC SQL
CREATE TABLE PAOLOR2.SYSTABLESR LIKE SYSIBM.SYSTABLES
ENDEXEC
EXEC SQL
ROLLBACK
ENDEXEC
EXEC SQL
INSERT INTO PAOLOR2.SYSTABLESR
SELECT * FROM SYSIBM.SYSTABLES
WHERE TYPE = 'T'
AND CREATOR LIKE 'PAOLOR%'
ENDEXEC
EXEC SQL
The result of this job is shown in Example 4-17. As you can see, all four EXEC SQL
statements executed successfully. We verified with SPUFI that the table
PAOLOR2.SYSTABLESR was successfully created and populated with 35 rows. So, the
EXEC SQL ROLLBACK statements did not influence the previous EXEC SQL statements.
Example 4-17 Verifying the commit scope of EXEC SQL
DSNU000I DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = CRLOAD
DSNU050I DSNUGUTC - EXEC SQL CREATE TABLE PAOLOR2.SYSTABLESR LIKE SYSIBM.SYSTABLES ENDEXEC
DSNU1180I DSNUGSQL - SQLCODE = 000, SUCCESSFUL EXECUTION
DSNU050I DSNUGUTC - EXEC SQL ROLLBACK ENDEXEC
DSNU1180I DSNUGSQL - SQLCODE = 000, SUCCESSFUL EXECUTION
DSNU050I DSNUGUTC - EXEC SQL INSERT INTO PAOLOR2.SYSTABLESR SELECT * FROM SYSIBM.SYSTABLES WHERE TYPE='T' AND
CREATOR LIKE 'PAOLOR%' ENDEXEC
DSNU1180I DSNUGSQL - SQLCODE = 000, SUCCESSFUL EXECUTION
DSNU1196I DSNUGSQL - SQLERRD = 0 0 35 1127790002 0 0 SQL DIAGNOSTIC INFORMATION
DSNU1196I DSNUGSQL - SQLERRD = X'00000000' X'00000000' X'00000023' X'4338B5B2' X'00000000' X'00000000' SQL
DIAGNOSTIC INFORMATION
DSNU050I DSNUGUTC - EXEC SQL ROLLBACK ENDEXEC
DSNU1180I DSNUGSQL - SQLCODE = 000, SUCCESSFUL EXECUTION
DSNU010I DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0
So, although you can code COMMIT and ROLLBACK statements, after the EXEC SQL
keyword, they do not influence the behavior of previous EXEC SQL commands.
Be aware that there are restrictions imposed by the EXEC SQL statement:
There are no select statements.
There is no control after error; the whole utility step stops after the first SQL error.
There is no concept of unit-of-work consisting of multiple SQL statements.
There are no comments possible between SQL statements.
However, some customizing steps have to be completed before you can use Cross Loader to
load data.
If the package for any reason is not available, you have to bind the package, as shown in
Example 4-19.
See the result of the bind in Example 4-22. Make sure that CURRENTDATA is set to NO. If
not, it will have a negative influence on the data transmission between the remote and the
local server.
Important: If you get the following error when loading from a cursor declared on a table
residing on an UNIX server:
UTILITY BATCH MEMORY EXECUTION ABENDED, REASON=X'00E4D5D2'
make sure that PTFs for PQ67037 and PQ62837 are applied to your DB2 system.
Rules for declaring a cursor for use with the Cross Loader
The following rules apply to the cursor you DECLARE in the EXEC SQL statement:
You must always declare the cursor before the LOAD statement. Otherwise, you get the
message DSNU1190I CURSOR NOT DECLARED.
The cursor name can only be declared once within the whole utility input stream. It can be
referred in multiple LOAD statements for LOADING different target tables with the same
data. If you declare an existing cursor, you get the error message: DSNU1189I CURSOR
ALREADY DECLARED.
The cursor name can only have up to eight characters.
The table being loaded cannot be part of the select statement. So you cannot LOAD into
the same table where you defined the cursor.
The column names in the result set of the select statement must be identical to the
column names in the table being loaded. This can be achieved by using the AS clause in
the SQL statement. If you have column names in the result set which do not match any
column name in the target table you get the error message: DSNU053I FIELD 'colname' NOT
FOUND or the error message: DSNU329I FIELD 'colnumber' IS NOT DEFAULTABLE.
Pay special attention to derived column names, which are the result of column functions
such as SUM or AVG.
You are able to skip unwanted columns in the result set with the LOAD IGNOREFIELDS
YES option, which skips any columns in the cursor result set that are not present in the
target table being loaded. However, use this IGNOREFIELDS option with care, as it also
skips misspelled columns you wanted to LOAD.
The sequence of the columns in the result set may differ from the sequence of the
columns in the table being loaded. DB2 matches the columns by their names and not by
their sequence.
The number of columns in the cursor can be less than the number of columns in the target
table. All missing columns are loaded with their default values. If the missing columns are
defined in the target table as NOT NULL without default, the LOAD fails with this message:
DSNU323I COLUMN 'colname' IS OMITTED.
If the data types in the target table do not match with the data types in the cursor, DB2
tries to convert as much as possible between compatible data types. Examples are from
CHAR to VARCHAR or from INTEGER to FLOAT. If the conversion fails, you get
messages like: DSNU390I INVALID CONVERSION FOR FIELD ‘columnname’ (conversion error
detected before the actual LOAD during the matching process) or DSNU334I INPUT FIELD
'columnname' INVALID FOR 'tablename', ERROR CODE cc (conversion error detected during the
LOAD). You might use DB2 supplied built-in functions or own developed UDFs in the SQL
statement to force more sophisticated conversions. An example is the CHAR function
which allows you to convert from INTEGER to CHARACTER.
If the encoding scheme of the source data in the cursor and the target table differ, DB2
automatically converts the encoding schemes. An example may be conversion from
EBCDIC to UNICODE or from ASCII to EBCDIC. Remember that referencing tables with
You can use any option of the Load utility except the following:
SHRLEVEL CHANGE: There is no support for online Load in the Cross Loader. If you
specify SHRLEVEL CHANGE, you get the message: DSNU070I KEYWORD OR OPERAND
'SHRLEVEL CHANGE' INVALID WITH INCURSOR.
FORMAT: You cannot specify the UNLOAD or SQL/DS formats.
FLOAT(IEEE): The cursor always returns FLOAT(S390.)
EBCDIC, ASCII, UNICODE: The Cross Loader always automatically converts the
encoding schemes. The target table must be created with the correct CCSID.
NOSUBS: You must accept substitution characters in a string.
CONTINUEIF: You cannot treat each input record as a part of a larger record.
WHEN: You cannot use the WHEN option to filter the result set of the cursor. Instead, filter
the result set by using the appropriate WHERE clauses in the select statement.
Field specifications: You cannot specify field specifications in the LOAD Statement. If
you specify field specifications, you get the message: DSNU331I FIELD LISTS ARE NOT ALLOWED
WITH INCURSOR KEYWORD.
The same cursor can be reused multiple times in the utility job step. It can be referenced in
different LOAD statements to load the same data in different target tables. It can also be
reused in one LOAD statement containing multiple INTO TABLE clauses to LOAD the same
data in different target tables (in the same table space.)
It is recommended that you load your data in clustering sequence. If loading from a sequential
data set this can be done by first sorting the sequential data set in clustering sequence. With
the Cross Loader this can be achieved by sorting the result set of the cursor by using an
ORDER BY statement on the clustering columns.
You can load partitions in parallel by specifying a different cursor for each partition.
Example 4-23 is a simple example of using the Cross Loader, where the columns in the
cursor match exactly the columns in the target table (same column names, same column
types, same order.)
Instead of *, in Example 4-24, we are using the column names in the select list.
In Example 4-25 we are loading with the same column names, but in a different order.
Example 4-25 Cross Loader example with columns in different order
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT DEPTNO, DEPTNAME, ADMRDEPT, LOCATION, MGRNO
FROM PAOLOR7.DEPT
In Example 4-26 we are loading only with columns that are not defined as default. If you omit
non-defaultable columns, the Load will terminate with:
COLUMN column name IS OMITTED
Example 4-26 Cross Loader example with non-default columns
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT DEPTNO, DEPTNAME, ADMRDEPT
FROM PAOLOR7.DEPT
ENDEXEC
LOAD DATA
INCURSOR C1
RESUME YES
INTO TABLE PAOLOR2.DEPT
In Example 4-27 we show how the SQL AS clause can be used to match the column names
in the cursor with the column names in the target table. You should use the SQL AS clause for
every derived column name that is the result of columns functions (SUM,MAX,..) or UDFs.
Example 4-27 Cross Loader example with AS clause in the column list
EXEC SQL
CREATE TABLE PAOLOR2.XDEPT
(XDEPTNO CHAR(3) NOT NULL,
XDEPTNAME VARCHAR(36) NOT NULL,
XMGRNO CHAR(6),
XADMRDEPT CHAR(3) NOT NULL,
XLOCATION CHAR(16))
ENDEXEC
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT DEPTNO AS XDEPTNO,
DEPTNAME AS XDEPTNAME,
MGRNO AS XMGRNO,
ADMRDEPT AS XADMRDEPT,
LOCATION AS XLOCATION
FROM PAOLOR7.DEPT
ENDEXEC
LOAD DATA
INCURSOR C1
RESUME YES
INTO TABLE PAOLOR2.XDEPT
In Example 4-28 we show the use of the IGNOREFIELDS YES LOAD option to ignore
columns in the cursor that are not present in the target table.
Example 4-28 Cross Loader example with IGNOREFIELDS
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT DEPTNO,
DEPTNAME,
MGRNO,
To test automatic conversion between encoding schemes, we declared three different tables
on the mainframe, see Example 4-29.
Example 4-30 shows the Cross Loading from one local EBCDIC table (PAOLOR7.EMP) to
the tables in Example 4-29.
Note: Make sure that the UNICODE translation table is activated with the necessary
translation combinations on the mainframe.
We will now LOAD a table containing UDT columns. In Example 4-31 we first create and
populate a table containing a UDT column. This UDT is defined as CHAR(3) WITH
COMPARISONS. We do not have to specify the appropriate casting function in the select list
of the cursor SQL statement to load the table.
Example 4-31 Cross Loader example of populating a table with UDT column
EXEC SQL
CREATE DISTINCT TYPE PAOLOR2.DEPT_OWNER AS CHAR(3) WITH COMPARISONS
ENDEXEC
EXEC SQL
In Example 4-32 we copy a subset of this table back to PAOLOR3.EXAMP3 with the Cross
Loader, converting the UDT back to the standard CHAR data type. We do not have to specify
any casting function in the select list of the cursor but we have to specify it in the WHERE
clause to create the subset. We only want to copy the rows corresponding with COL1 equals
to ‘SYSIBM’ and rename the CREATOR value to ‘SYSIBMX’ to prevent duplicate values in
PAOLOR3.EXAMP3. As we cannot use an Inline COPY with LOAD RESUME(YES), we have
to take the image copy with an additional COPY statement.
Example 4-32 Cross Loader example using a table with UDTs as source
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT
'A00' AS DEPTNO,
DEPTNAME,
MGRNO,
ADMRDEPT,
LOCATION
FROM PAOLOR2.YDEPT
WHERE DEPTNO = PAOLOR2.DEPT_OWNER('A00')
ENDEXEC
LOAD DATA
INCURSOR C1
RESUME YES
INTO TABLE PAOLOR2.DEPT
In Example 4-33 we populate a table containing a LOB column with the Cross Loader.
Remember that the maximum LOB size that can be transferred by the Cross Loader is 32 KB.
We first create the target base table, auxiliary table, and corresponding table spaces and
indexes with the EXEC SQL statement. We declare the ROWID as NOT NULL GENERATED
ALWAYS and do not copy the ROWID value from the source table. After the LOAD we collect
STATISTICS on all table spaces using a LISTDEF with the ALL LOB indicator keyword to
include both base and LOB table spaces.
Example 4-33 Cross Loader example with a LOB column
EXEC SQL
CREATE DATABASE PAOLOR3L
ENDEXEC
EXEC SQL
CREATE TABLESPACE DSN8S71B IN PAOLOR3L
USING STOGROUP DSN8G710
ENDEXEC
Cross Loader examples with remote source table and local target table
Cross Loader can transparently load data from a remote location connected through DRDA
definitions. Appendix B, “DB2 connectivity” on page 307 contains details on setting up the
necessary connectivity functions.
In Example 4-34 we use the Cross Loader to transfer data from a DB2 UDB database on a
UNIX server to DB2 for z/OS. The table in the UDB UNIX database is reached through DRDA
using its three part name.
Example 4-34 Cross Loader example loading from one remote location
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT *
FROM SAMPAIX.DB2INST1.DEPARTMENT
ORDER BY 1 DESC
In Example 4-35 we use the Cross Loader to transfer data from both a DB2 UDB database on
a UNIX server and from a Windows NT server to DB2 for z/OS.
Example 4-35 Cross Loader example loading from two remote locations
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT *
FROM SAMPAIX.DB2INST1.DEPARTMENT
ORDER BY 1 DESC
ENDEXEC
EXEC SQL
DECLARE C2 CURSOR FOR
SELECT *
FROM SAMPWIN.DB2INST1.DEPARTMENT
ORDER BY 1 DESC
ENDEXEC
LOAD DATA
REPLACE
INCURSOR C1
INTO TABLE PAOLOR2.DEPT
LOAD DATA
RESUME YES
INCURSOR C2
INTO TABLE PAOLOR2.DEPT
In Example 4-36 we try to use the Cross Loader to transfer the same data as in
Example 4-35, but we are using UNION ALL within one EXEC SQL. Referencing object from
two different locations is not allowed:
SQLCODE = -512, ERROR: STATEMENT REFERENCE TO REMOTE OBJECT IS INVALID
Example 4-36 Cross Loader example loading from two remote locations and one EXEC SQL
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT *
FROM SAMPAIX.DB2INST1.DEPARTMENT
UNION ALL
SELECT *
FROM SAMPWIN.DB2INST1.DEPARTMENT
ORDER BY 1 DESC
ENDEXEC
LOAD DATA
REPLACE
INCURSOR C1
INTO TABLE PAOLOR2.DEPT
In Example 4-37 we Load a partitioned table space with the Cross Loader. In this case we
only use one cursor. The source and target tables are identical.
In Example 4-38 we Load the same partitioned table space using partition parallelism.
Therefore, we declare one different cursor per partition, transferring the data belonging to that
particular partition.
Example 4-40 shows loading from a cursor declared on a distributed ASCII table to three
different tables on the mainframe:
PAOLOR2.EMPE is EBCDIC
PAOLOR2.EMPA is ASCII
PAOLOR2.EMPU is UNICODE
Example 4-40 Cross Loader conversion when loading from distributed to mainframe
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT * FROM SAMPAIX8.DB2INST2.EMPLOYEE
ORDER BY 1 DESC
ENDEXEC
LOAD DATA
INCURSOR C1 REPLACE
INTO TABLE PAOLOR2.EMPE
LOAD DATA
INCURSOR C1 REPLACE
INTO TABLE PAOLOR2.EMPA
LOAD DATA
INCURSOR C1 REPLACE
INTO TABLE PAOLOR2.EMPU
Cross loading is done using the new DB2 V7 option INCURSOR in the DB2 Load utility. With
this option you tell the Load to read the data from the result set of a cursor instead of reading
it from a sequential file. The data is read from the source location with a dynamic SQL
statement (enclosed between EXEC SQL and ENDEXEC statements) and loaded in a table
at the target location where the the Load utility runs.
The same cursor can be reused multiple times in the utility job step. It can be referenced in
different LOAD statements to load the same data in different target tables. It can also be
reused in one LOAD statement containing multiple INTO TABLE clauses to LOAD the same
data in different target tables (in the same table space.)
If the encoding scheme of the source data in the cursor and the target table differ, DB2
automatically converts the encoding schemes. An example may be conversion from EBCDIC
to UNICODE or from ASCII to EBCDIC.
Always sort the input data in clustering sequence before loading. Do this with an ORDER BY
clause when using the Cross Loader.
In addition to define a cursor, use EXEC SQL to execute dynamic SQL statements before,
between or after utility statements. It can simplify the JCL coding by eliminating dynamic SQL
applications like DSNTIAD or DSNTEP2 from the JCL stream and it enables to merge
different utility steps, separated by dynamic SQL applications, into one single utility step.
Some cross-platform examples are reported in Chapter 11, “Moving data to DB2 Distributed”
on page 267, and Chapter 10, “Moving data to DB2 for z/OS” on page 243.
Export utility runs on the client node, hence the output file will be created on the client node
as well. Version of the utility being executed depends on the version of DB2 installed on the
client machine.
The maximum size of a single LOB value that can be inlined in the export file is 32 KB. If the
source table contains larger LOB columns LOB data should be exported into separate a file
(or multiple files) by specifying the LOBSINFILE modifier. This is the only way to avoid data
truncation.
If you want to use the export data from a partitioned database, you can use db2batch to
complete the task at each database partition (see 2.3.3, “DB2 db2batch” on page 14, for
more information). The SELECT statement must be able to return only the data found locally.
A table can be saved by using the Export utility and specifying the IXF file format. The saved
table (including its indexes) can then be recreated using the Import utility.
For further information consult Chapter 1 of DB2 UDB Data Movement Utilities Guide and
Reference Version 8, SC09-4830.
In this example:
Only two columns (empno and picture) are exported
Non LOB data is exported to a delimited ASCII file ‘emp_photo.del’
Utility messages are placed in file ‘emp_photo.msg’
As LOBSINFILE modifier is used, LOB data stored in an external file
LOB data is stored in the lobs directory, and the base name used is emp_photo (if multiple
lob files need to be used, a three digit sequence number will be appended to this base
name.)
Prior to DB2 UDB V7.2 FixPak 7, Export utility creates a single file for each LOB object (in
later releases a lob file contains multiple LOB objects, as limited by the file system file size
restrictions.) If a large number of records containing LOB data needs to be exported both
‘lobs to’ and ‘lobfile’ can be specified. The utility can export up to 1000 lob objects for each
basename specified by the lobfile parameter. Multiple lob paths can be used to circumvent file
system space limitations:
export to emp_resume.ixf of ixf
lobs to lobs1/, lobs2/
lobfile e_r1.lob, e_r2.lob, e_r3.lob, e_r4.lob, e_r5.lob, e_r6.lob, e_r7.lob, e_r8.lob,
e_r9.lob, e_r10.lob, e_r11.lob, e_r12.lob, e_r13.lob, e_r14.lob, e_r15.lob, e_r16.lob,
e_r17.lob, e_r18.lob, e_r19.lob, e_r20.lob
modified by lobsinfile messages emp_resume.msg select * from emp_resume
In this example:
A maximum of 20000 records can be exported because 20 basenames for LOB files are
specified.
LOB data is exported to lobs1 directory, lobs2 directory is used only if the file system
hosting lobs1 fills up.
If you need more information on the operation of the Control Center you can view the online
Help facility inside the control center.
Examples of the export API invocation exist in the samples directory, inside the sqllib
directory. The files of interest are samples/c/expsamp.sqc, samples/c/impexp.sqc and
samples/c/tload.sqc (DB2 UDB V7), and samples/c/tbload.sqc, samples/c/tbmove.sqc and
samples/cpp/tbmove.sqC (DB2 UDB V8.)
The parameters for the Export utility API can be found in the IBM DB2 UDB Administrative
API Reference, SC09-4824.
Import utility runs on the client node, hence the source file has to be located on the client
node as well. Version of the utility being executed depends on the version of DB2 installed on
the client machine.
When invoking the Import utility you need to specify the following:
The path, name, and type of the input file. Import utility supports DEL, ASC, PC/IXF, and
WSF file formats.
You can use the Import utility to recreate a table that was saved through the Export utility. The
table must have been exported to an IXF file, and the SELECT statement used during the
export operation must have met certain conditions (for example, no column names can be
used in the SELECT clause; only select * is permitted). When creating a table from an IXF
file, not all attributes of the original table are preserved. For example, referential constraints,
foreign key definitions, and user-defined data types are not retained.
By default, the Import utility is bound to the database with isolation level RR (repeatable
read). If a large number of rows is being imported into a table, the existing lock may escalate
to an exclusive lock. If another application working on the same table is holding some row
locks, a deadlock will occur if the lock escalates to an exclusive lock. To avoid this, the Import
utility requests an exclusive lock on the table at the beginning of its operation. Holding a lock
on the table has two implications. First, if there are other applications holding a table lock, or
row locks on the Import target table, the Import utility will wait until all of those applications
commit or roll back their changes. Second, while Import is running, any other application
requesting locks will wait until the Import operation has completed.
In a partitioned database environment, the Import utility can be enabled to use buffered
inserts. This reduces the messaging that occurs when data is imported, resulting in better
performance; however, since details about a failed buffered insert are not returned, this option
should only be enabled if you are not concerned about error reporting.
For further information consult Chapter 2 of DB2 UDB Data Movement Utilities Guide and
Reference Version 8, SC09-4830.
Restrictions
This utility does not support the use of nicknames.
If the existing table is a parent table containing a primary key that is referenced by a
foreign key in a dependent table, its data cannot be replaced, only appended to.
You cannot perform an Import replace operation into an underlying table of a materialized
query table defined in refresh immediate mode.
You cannot Import data into a system table, a summary table, or a table with a structured
type column.
You cannot Import data into declared temporary tables.
Views cannot be created through the Import utility.
Referential constraints and foreign key definitions are not preserved when creating tables
from PC/IXF files. (Primary key definitions are preserved if the data was previously
exported using SELECT *.)
Because the Import utility generates its own SQL statements, the maximum statement
size of 64KB may, in some cases, be exceeded.
Import utlity logs all record inserts. If log space is scarce specify a commitcount option to
have the utility periodically issue commit statements to empty the logs and release locks.
Import utility holds an exclusive lock on the target table. If concurrency is an issue, use
Load with ALLOW READ ACCESS option to give other applications concurrent (read only)
access to the target table.
Note: If an error occurs during an IMPORT REPLACE operation, the original data in the
table is lost. If COMMITCOUNT was specified, data already committed will be available
immediately after the failure. Retain a copy of the input data to allow the Import
operation to be restarted.
To Import data from a positional ASCII file, with LOB data saved in an external file:
import from emp_photo.asc of asc lobs from lobs/ modified by lobsinfile reclen= 31
method l (1 6, 8 17, 19 30) null indicators (7, 18, 31) messages emp_photo.msg insert
into emp_photo
In this example:
– The target table is truncated before any new data is inserted, note that rows may still
be rejected if there are unique index violations.
– Since the input data is ASC a method parameter must specify columns’ positions
inside the fixed length records.
– Positions of null indicators are also specified.
– LOB data is read from the lobs directory.
If an unique index is defined on the target table insert_update mode can be used:
import from emp_resume.ixf of ixf messages emp_resume.msg insert_update into emp_resume
In this example records from the input file will be inserted if there is no primary key match,
if a primary key match is found table record will be updated with new data.
If you need more information on the operation of the Control Center you can view the online
Help facility inside the control center.
Examples of the Import API invocation exist in the samples directory, inside the sqllib
directory. The files of interest are samples/c/expsamp.sqc and samples/c/impexp.sqc (DB2
UDB V7), and samples/c/dtformat.sqc, samples/c/tbmove.sqc and samples/cpp/tbmove.sqC
(DB2 UDB V8.)
The parameters for the Import utility API can be found in the IBM DB2 UDB Administrative
API Reference, SC09-4824.
The Load utility is capable of efficiently moving large quantities of data into empty tables, or
into tables that already contain data. It can handle most data types, including large objects
(LOBs), user-defined types (UDTs), and DATALINKs. It is much faster than the import utility,
because it writes formatted pages directly into the database, while the import utility performs
SQL INSERTs. It does not fire triggers, and does not perform referential or table constraints
checking (other than validating the uniqueness of the indexes.)
The Load utility runs on the server. The version of the utility being executed depends on the
version of DB2 installed on the server machine. There are restrictions on the Load options
available if Load is invoked through a down level client.
There are several processes that happen internally to ensure the integrity of the data and the
efficient performance of the database. On each partition where the target table resides, the
work performed by the Load utility can be categorized into different phases. In this section, we
will discuss these per-partition phases.
Messages about rejected rows are written to the Load message file. Following the completion
of the Load process, review these messages and correct problems appropriately.
If a failure occurs during the Load phase, you can restart the Load operation; the RESTART
option automatically restarts the Load operation from the last successful consistency point.
The TERMINATE option rolls back the failed Load operation. Note that REPLACE option
requires a table truncation before new data is inserted. This truncation is irreversible.
If a failure occurs during the build phase, the RESTART option automatically restarts the Load
operation at the appropriate point.
If a failure occurs during the delete phase, the RESTART option automatically restarts the
Load operation at the appropriate point.
Note: Each deletion event is logged. If you have a large number of records that violate the
uniqueness condition, the log could fill up during the delete phase. Load utility also logs
splits done on index object pages.
If a failure occurs during the index copy phase, the RESTART option automatically restarts
the Load operation at the appropriate point.
When logretain is on, loads are run with one of the following recovery options:
COPY YES
– A copy of the loaded data is generated as the Load takes place (COPY YES.)
Subsequent roll forward processing will process the copy and update the table
accordingly.
COPY NO
– No copy is taken (which will speed up processing), however, the tablespaces where the
loaded table is defined are placed in backup pending. This means that the only
allowable updates to those tablespaces will be through running the Load utility.
Performing reads to tables in those table spaces is still permitted, however. The backup
pending state persists until a backup of those tablespaces (or the entire database) is
taken.
NONRECOVERABLE
– No copy is taken, however, the tablespaces where the loaded table is defined are not
placed in backup pending. This is meant as a convenience so that access to table
spaces will not be restricted after loads are performed. However, there is risk
associated with this convenience. If roll forward processing encounters a
In its most common mode, SPLIT_AND_LOAD, db2atld partitions input data into as many
output sockets as there are database partitions in which the target table is defined. While
doing this, it performs a Load operation (see 6.1.1, “Per-partition Load operation” on page 92
for details) concurrently on each of these partitions, where each Load reads partitioned data
from its designated output socket. A key feature of db2atld is that it uses direct TCP/IP
communication using sockets for all data transfer required during both the partitioning and
loading processes. It is also capable of running multiple processes to parallelize the
partitioning of data, thereby significantly improving performance.
db2atld supports delimited (DEL) and positional (ASC) ASCII files. It is not possible to use
this utility to load PC/IXF files.
Input parameters for db2atld are set in the AutoLoader configuration file. An example is
shown in Section 6.4, “Using the Load utility” on page 99.
For further information on the AutoLoader executable please refer to Chapter 4 of the DB2
UDB Data Movement Utilities Guide and Reference Version 7, SC09-4830.
Before a Load operation in ALLOW READ ACCESS mode begins, the Load utility will wait for
all applications that began before the Load operation to release locks on the target table.
Since locks are not persistent, they are supplemented by table states that will remain even if a
Load operation is aborted. These states can be checked by using the LOAD QUERY
command. By using the LOCK WITH FORCE option, the Load utility will force applications
holding conflicting locks off the table that it is trying to load into.
At the beginning of a Load operation in ALLOW READ ACCESS mode, the Load utility
acquires a share lock (S-lock) on the table. It holds this lock until the data is being committed.
The share lock allows applications with compatible locks to access the table during the Load
operation. For example, applications that use read only queries will be able to access the
table, while applications that try to insert data into the table will be denied. When the Load
utility acquires the share lock on the table, it will wait for all applications that hold locks on the
table prior to the start of the Load operation to release them, even if they have compatible
locks. Since the Load utility upgrades the share lock to an exclusive (Z-lock) when the data is
being committed, there may be some delay in commit time while the Load utility waits for
applications with conflicting locks to finish.
The db2atld executable is no longer needed, since all of the modes and options supported by
the AutoLoader can now be used with the Load utility to achieve the same results. To
preserve backward compatibility, however, a db2atld executable is included in DB2 UDB V8. It
It is recommended that the messages option be specified for a partitioned load. If it is not
specified, Load will only display the final sqlcode reported by each of the loading and
partitioning processes, and other warnings and errors encountered during processing will not
be made available to the user.
Note that each partition will be attempting to load a complete copy of the PC/IXF datafile. This
means that many rows will be rejected in each partition. The number of rows read will be n*r ,
where n is the number of partitions where the target table is defined on, and r is the number of
To execute a crossload through CLP, a cursor must first be declared against an SQL query.
Once this is done, simply execute the Load specifying the cursoriness as the source, and
CURSOR as the source type. Please refer to 6.4.1, “Invoking the Load utility” on page 100 for
an example.
The same result can be achieved through calling the db2Load API in an embedded SQL
application. For an example, see Example 6-1 on page 108.
The Load utility does not perform any extra validation of user-supplied identity values beyond
what is normally done for values of the identity column's data type (that is, SMALLINT, INT,
BIGINT, or DECIMAL). Duplicate values will not be reported.
The Load utility can be used to load data into a table containing (non-identity) generated
columns. The column values will be generated by this utility. If no generated column-related
file type modifiers are used, the Load utility works according to the following rules:
Values will be created for generated columns when the corresponding row of the data file
is missing a value for the column or a NULL value is supplied. If a non-NULL value is
supplied for a generated column, the row is rejected (SQL3550W).
If a NULL value is created for a generated column that is not nullable, the entire row of
data will be rejected (SQL0407N). This could occur if, for example, a non-nullable
generated column is defined as the sum of two table columns that include NULL values in
the data file.
When using the LOAD command with MDC, violations of unique constraints will be handled
as follows:
If the table included a unique key prior to the load operation and duplicate records are
loaded into the table, the original record will remain and the new records will be deleted
during the delete phase.
If the table did not include a unique key prior to the load operation and both a unique key
and duplicate records are loaded into the table, only one of the records with the unique key
will be loaded and the others will be deleted during the delete phase.
Note: There is no explicit technique for determining which record will be loaded and
which will be deleted.
Performance considerations
To improve the performance of the Load utility when loading MDC tables, the UTIL_HEAP_SZ
database configuration parameter should be set to a value that is 10-15% higher than usual.
This will reduce disk I/O during the clustering of data that is performed during the load phase.
When the DATA BUFFER option of LOAD command is specified, its value should also be
increased by 10-15%. If the LOAD command is being used to load several MDC tables
concurrently, the UTIL_HEAP_SZ configuration parameter should be increased accordingly.
MDC load operations will always have a build phase since all MDC tables have block indexes.
During the load phase, extra logging for the maintenance of the block map will be performed.
There are approximately two extra log records per extent allocated. To ensure good
performance, the LOGBUFSZ database configuration parameter should be set to a value that
takes this into account.
A system temporary table with an index is used to load data into MDC tables. The size of the
table is proportional to the number of distinct cells loaded. The size of each row in the table is
proportional to the size of the MDC dimension key. To minimize disk I/O caused by the
manipulation of this table during a load operation, ensure that the buffer pool for the
temporary table space is large enough.
Restrictions
The Load utility cannot perform the following operations:
Load data into a declared temporary table
Load data into nicknames
Load data into hierarchical tables
Load data into typed tables, or tables with structured type columns
Create tables before loading into them
Load data into a database accessed through DB2 Connect or a server level that is not
supported
Activate triggers on newly loaded rows, business rules associated with triggers are not
enforced by the Load utility.
Note: If an error occurs during a LOAD REPLACE operation, the original data in the table
is lost. Retain a copy of the input data to allow the Load operation to be restarted.
Note: These examples use relative path names for the Load input file. Relative path names
are only allowed on Load requests from a locally connected client. The use of fully qualified
path names is recommended.
The following example performs an “online” Load, allowing other applications read access to
table data. The example is specific to DB2 UDB V8:
load from inputtab.ixf of ixf messages inputerr.msgs
insert into staff indexing mode rebuild allow read access use tmpspace
In this example:
– Load is online, as ‘allow read access’ is specified.
– Table indices are temporarily rebuilt in a table space named tmpspace before the index
table space data is copied over to its defined location.
The following example loads a delimited ASCII file into a table residing in a partitioned
database. Therefore, the example is specific to DB2 UDB V8:
load from inputtab.del of del messages inputerr.msgs
replace into staff partitioned db config mode partition_and_load
partitioning_dbpartnums(0,1) output_dbpartnums(1,2,3)
In this example:
– Options specific to partitioned database environments are specified after the
‘partitioned db config’ parameter.
– As the PARTITION_AND_LOAD mode is used, data is both partitioned and loaded
simultaneously.
– Data partitioning is performed on partitions 0 and 1.
– Load operations are being performed on partitions 1, 2 and 3.
The following example, which is specific to DB2 UDB V8, performs a cross load, loading the
contents from one table into another.
connect to mydb
DECLARE mycurs CURSOR FOR SELECT TWO,ONE,THREE FROM abc.table1
LOAD FROM mycurs OF cursor messages messages.txt INSERT INTO abc.table2
connect reset
In this example:
abc.table2:
ONE VARCHAR(20)
TWO INT
THREE DATE
– All the data contained inside abc.table1 was loaded into abc.table2, saving Load
messages to the file messages.txt:
The complete syntax for the Load command can be interactively checked from the online
Command Reference or by issuing ‘db2 ? load’ command from the command window.
6. Use the Columns page to define the mapping between input data and target columns,
choose identity and generated column behavior and set LOB options. See Figure 6-4.
7. As in the Import Notebook, A graphical column mapper is available when ASC file is used.
Figure 5-7 on page 89.
8. Use the Performance page to choose minimal checking (FASTPARSE modifier), check
pending option and force option, to set the index build mode and statistics mode, and to
select free page options. See Figure 6-5.
9. Use the Recovery page to set the crash recovery options and the forward recovery options
(Load copy options). See Figure 6-6.
10.Use the Options page to set more advanced Load options. Hint section gives the
explanation of the selected option. See Figure 6-7.
11.Use the Schedule page to create a scheduled task in the Task Center. See Figure 6-8.
12.Before executing the command, Review the selected Load task shown on the Summary
page. Figure 6-9.
If you need more information on the operation of the Control Center you can view the online
Help facility inside the control center.
Load API
The Load utility can be invoked through the Application Programming Interface. A database
connection needs to exist before the Load is performed.
As of DB2 UDB V8, the recommended Load API is db2Load(). For previous versions,
sqluload() is used.
Examples of the Load API invocation exist in the samples directory, inside the sqllib directory.
The files of interest are samples/c/tload.sqc and samples/cobol/tload.sqb (DB2 UDB V7), and
samples/c/tbload.sqc, samples/c/tbmove.sqc and samples/c/dtformat.sqc (DB2 UDB V8.)
Example 6-1 demonstrates how the db2Load() API can be used to perform a cross load.
int loadAndDisplayResults
(
db2LoadStruct *pLoadStruct,
struct sqlca *pSqlca
)
{
printf("\n");
iRowsRead = pLoadOut->oRowsRead;
printf("Number of rows read : %d\n", iRowsRead);
iRowsSkipped = pLoadOut->oRowsSkipped;
printf("Number of rows skipped : %d\n", iRowsSkipped);
iRowsLoaded = pLoadOut->oRowsLoaded;
printf("Number of rows loaded : %d\n", iRowsLoaded);
iRowsRejected = pLoadOut->oRowsRejected;
printf("Number of rows rejected : %d\n", iRowsRejected);
iRowsDeleted = pLoadOut->oRowsDeleted;
printf("Number of rows deleted : %d\n", iRowsDeleted);
iRowsCommitted = pLoadOut->oRowsCommitted;
printf("Number of rows committed : %d\n", iRowsCommitted);
}
else
{
char sqlcaString[1024];
sqlaintp(sqlcaString, 1024, 70, pSqlca);
printf("%s", sqlcaString);
}
exit:
return rc;
}
char sqlStmt[1024];
memset(&CopyTargetList, 0, sizeof(CopyTargetList));
memset(&MediaEntry, 0, sizeof(MediaEntry));
memset(&DataFileList, 0, sizeof(DataFileList));
memset(&StatementEntry, 0, sizeof(StatementEntry));
memset(&DataDescriptor, 0, sizeof(DataDescriptor));
memset(&loadIn, 0, sizeof(loadIn));
memset(&loadOut, 0, sizeof(loadOut));
memset(&loadStruct, 0, sizeof(loadStruct));
loadStruct.piSourceList = &DataFileList;
loadStruct.piLobPathList = NULL;
loadStruct.piDataDescriptor = &DataDescriptor;
loadStruct.piFileTypeMod = NULL;
loadStruct.piTempFilesPath = NULL;
loadStruct.piVendorSortWorkPaths = NULL;
loadStruct.piCopyTargetList = NULL;
loadStruct.piNullIndicators = NULL;
loadStruct.piLoadInfoIn = &loadIn;
loadStruct.poLoadInfoOut = &loadOut;
pLocalMsgFileName = "messages.txt";
loadStruct.piLocalMsgFileName = pLocalMsgFileName;
DataFileList.media_type = SQLU_SQL_STMT;
DataFileList.sessions = 1;
DataFileList.target.pStatement = &StatementEntry;
DataFileList.target.pStatement->pEntry = xloadQuery;
DataDescriptor.dcolmeth = SQL_METH_D;
sprintf(tempChar, "INSERT INTO abc.table2");
if (pActionString == NULL)
{
printf("Error allocating action string!\n");
rc = -1;
goto exit;
}
printf("
==========================================================================\n");
printf(" CROSSLOAD STARTING.\n");
printf("
==========================================================================\n");
loadAndDisplayResults(&loadStruct, &sqlca);
printf("
==========================================================================\n");
printf(" CROSSLOAD FINISHED.\n");
printf("
==========================================================================\n");
if (pActionString != NULL)
{
free(pActionString);
}
exit:
return rc;
}
The parameters for the Load utility APIs can be found in the appropriate versions of the IBM
DB2 UDB Administrative API Reference, SC09-4824.
Sort capability
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. Exception tables can be used as a repository for unique key
violations.
Referential Integrity
The Load 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 a check pending state. Summary tables that are defined
with REFRESH IMMEDIATE, and that are dependent on tables being loaded, are also placed
in a 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. For
clustering indexes, the data should be sorted on the clustering index prior to loading. The
data need not be sorted when loading into an multi-dimensionally clustered (MDC) table.
Utilities were executed in replace mode, with messages parameter specified. Tables from the
sample database were populated with randomly generated data.
These results should not be used to compare performance of DB2 UDB V8 to V7 because
tests were ran on different physical setups. By repeating some measurement we estimate a
5% error on the ratios of execution times in non-partitioned environments. Because of
necessary network traffic and more complex processing model, this uncertainty is larger in
partitioned environments. Our estimate here is 10%.
Non-partitioned sample database on Windows platform was used for the analysis
summarized in Table 6-1. Target table (staff) does not contain any LOB or LONG columns. No
indices are defined on the table. All reported times are in seconds.
Table 6-1 Comparison of Import and Load execution times on Windows platform
DB2 Rows Format Import (s) Load (s) Ratio
Load utility outperformed import by roughly a factor of 10. Differences between different
formats (PC/IXF, delimited ASCII, fixed length positional ASCII) are on the 10% level.
Partitioned and non-partitioned sample databases on UNIX platform were used for the
analysis summarized in Table 6-2. Target table (emp_photo) does contain a LOB column. Two
dimensional primary key is defined on the table. All reported times are in seconds.
Table 6-2 Comparison of Import and Load execution times on UNIX platform
DB2 Partitions Rows Format Import (s) Load (s) Ratio
V7 1 2M ASC - -
V8 1 2M ASC - -
Load outperforms Import in all scenarios. The ratio of import execution time to Load execution
time in non-partitioned DB2 UDB V8 (a factor of 6) is considerably smaller than in partitioned
DB2 UDB V8 and in non-partitioned DB2 UDB V7 (a factor of 12 and 18 respectively.)
Table 6-3 Summary of important differences between the DB2 Load and Import utilities.
Import utility Load utility
Slow when moving large amounts of data. Faster than the import utility when moving large
amounts of data, because the Load utility writes
formatted pages directly into the database.
Creation of tables, hierarchies, and indexes Tables and indexes must exist.
supported with PC/IXF format.
No support for importing into materialized query Support for loading into materialized query
tables. tables.
Supports import into tables and views. Supports loading into tables only.
All constraints are validated during an import The Load utility checks for uniqueness and
operation. computes generated column values, but all other
constraints must be checked using SET
INTEGRITY.
The key values are inserted into the index one at The key values are sorted and the index is built
a time during an import operation. after the data has been loaded.
If updated statistics are required, the runstats Statistics can be gathered during the Load
utility must be run after an import operation. operation if all the data in the table is being
replaced.
You can import into a host database through DB2 You cannot load into a host database.
Connect.
Input data must reside on the same machine that Input data can reside on the server, or on the
the import utility is invoked. remotely connected client from which the Load
utility is invoked.
A backup image is not required. Because the A backup image can be created during the Load
import utility uses SQL inserts, DB2 logs the operation.
activity, and no backups are required to recover
these operations in case of failure.
The HPU provides efficient use of CPU processing power by working down to the VSAM level
instead of using SQL and going through DB2. The utility directly accesses the VSAM clusters
that DB2 uses to store its tables spaces. This direct use of VSAM takes maximum advantage
of VSAM’s buffering capability, which lets an entire cylinder be read with a single I/O.
Some other advantages of HPU is its ability to perform parallel unloads of different tables
under one tablespace by using multiple SQL statements. It can also unload from image
copies, hence lessening the interference with the DB2 production database. It can do
selective unload of rows and columns. With the use of HPU user exit, it can inspect, modify, or
discard DB2 rows.
Reading large amount of data in a sequential manner substantially increases the amount of
time needed to complete the unload task. Hence, making this task fit in the 10 to 12 hour
batch window that you usually have is becoming harder as time goes by. Efficiency becomes
a primary criterion in selecting tools and utilities to be used in the database shop.
HPU helps to increase productivity and task efficiency by performing the data unload in
parallel manner. Reading the different tables at the same time and performing several
unloads concurrently using an image copy significantly increase the amount of work that can
be done in a given time.
The HPU provides an extremely fast way to sequentially read and share a DB2 tablespace
among multiple tasks. This is needed to avoid the potential problem in the DB2 buffer pool
management when multiple programs compete for the same data. It avoids writing over
buffers that may be serving several unloads and potential channel conflicts. By optimizing
sequential reads of the table space, HPU will reduce both the elapsed and CPU time needed
to execute the unloads.
In most cases, you can use the same system to install the HPU. However, there are cases
where it is necessary to use a different driving system and target system. One reason for
using a separate installation system is if you want one program having different versions to
run in parallel with each other. This is done when you want the older and more stable version
to run in the production LPAR (logical partition) and the new and untested version to run in the
test LPAR. Another case where it is necessary to use a separate installation system is when
the program you are installing shares a program library or load modules with other products
running in your system. And you want the installation not to disrupt the programs running in
the production LPAR.
The hardware requirement is any mainframe hardware (such as machine type 9672, 2066,
2064) that can run the software requirement.
Negative requisites
Negative or incompatibility requisites are products that cannot exist on the same system with
the one being installed. A given product is mutually exclusive with its negative requisite.
HPU has no negative requisites.
Storage requirements
HPU requires:
1470 blocks for the target system
1470 blocks for the distribution system
Notes: IBM recommends use of system determined block sizes for efficient disk utilization
for all non-RECFM U data sets. For RECFM U data sets, IBM recommends a block size of
32760, which is the most efficient from a performance and DASD utilization perspective.
All target and distribution libraries listed have the following attributes:
The default name of the data set may be changed.
The default block size of the data set may be changed.
The data set may be merged with another data set that has equivalent characteristics.
The data set may be either a PDS or a PDSE.
All target libraries listed which contain load modules have the following attributes:
The data set may be in the LPA.
It is not required for the data set to be in the LPA.
The data set may be in the LNKLST.
It is not required for the data set to be APF authorized.
There are FMIDs that could be deleted when you install the HPU. You should check the
++VER part of the SMPMCS. If you find some FMIDs that you do not want to be deleted
you should install the HPU in a different SMP/E target and distribution zone.
In the download JCL, tunit is the unit value matching the product tape, volser is the volume
serial which is described in the CBPDO documentation, X is the tape file number where the
data set name is on the CBPDO tape (refer to the documentation provided by CBPDO to see
where IBM.HINZ210.F2 is located on the CBPDO tape), filevol is the volume serial of the
DASD device where the downloaded files reside, jcl-library-name is the name of the output
data set where the sample jobs will be stored, dasdvol is the volume serial of the DASD
device where the output data set will reside, and indd is either TAPEIN or FILEIN depending
on your input DD statement.
Expected Return Codes and Messages: You will receive a return code of 0 if this job runs
correctly.
Expected Return Codes and Messages: You will receive a return code of 0 if this job runs
correctly.
Edit and submit sample job INZRECEV to perform the SMP/E RECEIVE for HPU. Consult the
instructions in the sample job for more information.
Expected Return Codes and Messages: You will receive a return code 0 if this job runs
correctly.
Expected Return Codes and Messages: You will receive a return code 0 if this job runs
correctly.
Expected Return Codes and Messages: You will receive a return code 0 if this job runs
correctly.
But before you run the SMP/E accept job you must first do a requisite check-up on the
system. So you should first do an APPLYCHECK before you do your SMP/E APPLY. The
APPLY CHECK is done with the same job just that the CHECK parameter is present in the
JCL. When this JCL is run with this parameter there will be no changes done but you will see
the HOLDDATA or errors that prevented you from having a successful execution.
Once you have taken any actions indicated by the APPLY CHECK, remove the CHECK
operand and run the job again to perform the APPLY, see Example 7-2.
Note: The GROUPEXTEND operand indicates that SMP/E apply all requisite SYSMODs.
The requisite SYSMODS might be applicable to other functions.
Expected Return Codes and Messages from APPLY CHECK: You will receive a return
code 0 if this job runs correctly.
Expected Return Codes and Messages from APPLY: You will receive a return code 0 if this
job runs correctly.
Important: This step is required only for first time users of HPU.
Go to the ISPF panel P.3.2. Allocate a PDS for use by the INZT02 procedure, which stores a
backup of the configuration data set (member INZTVAR).
Any value of BLKSIZE that is a multiple of the LRECL, SPACE=(TRK,(1,1,5)). The name of
this library must be entered in member INZTDSN. See “Step 3: Editing the INZTDSN
member” on page 128.
Figure 7-1 Sample data set information for allocating the INZRSAVE library
You can execute this REXX procedure by going to the P.3.4 ISPF panel and typing ‘exec’ on
the line beside it. See Figure 7-2
in the command field and press Enter.The generation process creates a member called
INZTVAR in the SINZSAMP library.The response “Generation was OK” will be returned.
Reinstallation
If you have already customized a previous version of the product, do the following:
1. Execute the INZT01 procedure located in the SINZSAMP library.
2. Enter the name of the previous INZRSAVE data set in the field “Old file of variables to be
retrieved” in the format dsname(member).
Some of the variables in this member will already contain values retrieved from the
INZRSAVE member of the previous installation.
To verify if your job ran successfully go to the SINZAMP library and look for the INZTVAR.
This member appears after the successful run of the INZT01.
Example 7-3 INZTDSN JCL — Replace the ‘??hlq??’ with your high level qualifier
//************************************************************************
//**
//*ENTER BELOW THE DSNAMES OF THE FILES THAT WILL CONTAIN THE *
//*CUSTOMIZEDMEMBERS *
//**
//************************************************************************
//*
//*LIBRARY THAT CONTAINS THE BACKUP OF THE VARIABLES FILE
//INZRSAVE ??HLQ??.SINZRSAVE
//*
//*SAMPLE LIBRARY
//INZSAMP ??HLQ??.SINZSAMP
//*
//*LIBRARY FOR DB2 UNLOAD PARMLIB
//*NOTE:IT CAN BE THE SAME LIBRARY AS THE SAMPLE LIBRARY ABOVE
//INZPLIB ??HLQ??.SINZSAMP
//*
//*CLIST LIBRARY
//INZCLST ??HLQ??.SINZCLST
//*ISPF SKELETONS LIBRARY
//INZSLIB ??HLQ??.SINZSLIB
Note: Depending on your installation’s standards, this library can be the SINZSAMP library
or any library chosen to contain HPU’s PARMLIB members. The same library should be
used to set variable VIZ007 in the INZTVAR member.
This member contains the definition of the variables used to create the installation JCL and
the INZUTIL member that contains the product parmlib.
This member is the input of the INZ02 job that has to be run after this member is edited.
If you encounter any error in the parameters of the installation JCL generated by these
members, you should not change the variables in the JCL directly. You must go back to the
INZTVAR or INZTDSN and change the values there then rerun the INZ02 or INZ01 job.
Any manual modification on the installation JCL generated by the INZ02 will be lost once the
INZ02 is rerun.
In our example, ‘INZ.V2R1M0’ is the high level qualifier of the installation data sets. a sample
of the JCL portion that needs to be modified is in Example 7-6 on page 132. The JCL
Tip: If you ned to know the high level qualifiers of the DB2 libraries that you are using, you
can see them in the job that started DB2 Master address space. You can view this in the
SDSF panel Active Users (DA option). Look for the jobname with MSTR suffix. You can do
this by typing ‘pre *MSTR’ inside the DA panel command line. Then open the job that has
your subsystem name on as the prefix.
************************************************************************
*
******************* DEFAULT JCL PARAMETERS *****************************
*
* JOB CARDS FOR JCL
* (UP TO 5 LINES, BETWEEN THE COL=19 AND THE COL=72)
* ******************************************************
VIM101 //PAOLOHPU JOB PAOLOR21,'DB2 UNLOAD',
VIM102 // MSGCLASS=A,CLASS=A,NOTIFY=&SYSUID,
VIM103 // REGION=0M
VIM104 //*
VIM105 //*
* ******************************************************
VIM101 to VIM105 Enter your job card. Ensure that you include a
region size on the job card; failure to do so can
result in abend s106 when running HPU
interactively.
Example 7-6 shows how to define the DB2 libraries and subsystem name. These values are
required to be edited. The values in italics are the ones that needs to be supplied by the user.
These values depend on the DB2 set-up where HPU is being installed.
Example 7-6 INZTVAR JCL — Defining the DB2 libraries and subsystem name.
******************* COMMON DB2 PARAMETERS ******************************
*
* NOTE: IF YOU WANT TO INSTALL THE PRODUCT ON SEVERAL DB2 SYBSYSTEMS
* YOU SHOULD DUPLICATE THE DEFINITION OF SOME VARIABLES,
* ONE FOR EACH SUBSYSTEM.
* BE CAREFUL TO CODE THE VARIABLES THAT CORRESPOND TO THE
* DIFFERENT SUBSYSTEMS IN THE SAME ORDER FOR EACH VARIABLE.
*
* DB2 SUBSYSTEMS
VZD001 DB2G
* VZD001 LINE TO DUPLICATE TO SPECIFY OTHER DB2 SUBSYSTEM
*
* LIBRARY WHICH CONTAINS DB2 LOAD-MODULES (DSNLOAD)
VZD003 DB2G7.SDSNLOAD
* VZD003 LINE TO DUPLICATE FOR DSNLOAD OF OTHER DB2 SUBSYSTEM
*
* LIBRARY WHICH CONTAINS DB2 RUNLIB LOAD-MODULES (DSNTIAD)
VZD004 DB2V710G.RUNLIB.LOAD
* VZD004 LINE TO DUPLICATE FOR RUNLIB OF OTHER DB2 SUBSYSTEM
*
* PLANS CORRESPONDING TO DSNTIAD PROGRAM
VZD005 DSNTIA71
* VZD005 LINE TO DUPLICATE FOR DSNTIAD PLAN OF OTHER DB2
*
*
* DB2 DSNEXIT LIBRARY
VZD007 DB2V710G.SDSNEXIT
* VZD007 LINE TO DUPLICATE FOR DSNEXIT OF OTHER DB2 SUBSYSTEM
*
*
* IBM CONVERSION SERVICE LOAD LIBRARY
* LOAD LIB THAT CONTAINS CUNLCVN (IBM DOCNUM GI10-9760)
* (OPTIONAL)
VZM006 SCUNMOD
*
HPU parameters
Table 7-7 describes the most common HPU parameters.
Specify one value for each DB2 subsystem defined with variable VZD001.
You can control the internal function parameters of the HPU by entering the values on the
INZTVAR member. The JCL portion appears in Example 7-7.
Example 7-7 JCL portion where the HPU parameters are set
*
*APPLICATION PLAN FOR THE PRODUCT
VUM011 PLANOBJT ????????
*
*OWNER OF THE PLAN CREATEDFOR THE PRODUCT
VUM012 ????????
*VUM012 LINE TO DUPLICATE FOR PLAN OWNER IN OTHER DB2
*
*PUBLIC OR USER (GRANT ON THE PLAN CREATEDFOR THE PRODUCT)
VUX011 ??????
*VUX011 LINE TO DUPLICATE FOR OTHER DB2 SUBSYSTEM
*
*UNIT NAME FOR ALLOCATION OF TEMPORARY DATASETS
/VUM013 WRKUNIT &VIM111
*
*VOLUME(S)FOR ALLOCATION OF TEMPORARY DATA SETS
*(OPTIONAL)
VUM018 WRKVOL
*
*TAPE UNIT WHERE THE WORK DATASETS MUST BE ALLOCATED
*(OPTIONAL)
VUA007 WRKTUNIT
*
*MAXIMUM SIZE FOR WORK DATASET ON DASD (IN KILOBYTES)
VUX016 WRKUNTSW
*
*MAXIMUM NUMBER OF UNIT FOR TAPE TEMPORARY DATASET
VUX017 MAXTUNIT
*
*LIMIT NUMBER OF MESSAGES THAT ARE ISSUEDIF ANY ERROR
*CONCERNING THE STRUCTURE IS ENCOUNTEREDWHILE READING THE
*ROWS OF A TABLESPACE
*(OPTIONAL)
*VUX018 LDSERRLM
*
*QUIESCE OF SYSDBASE AND DBD01 FOR THE BATCH UTILITIES
*(YES/NO/OFF/FORCE)
VUM014 QUIESCAT YES
*
*USER USEDTO QUIESCE THE CATALOG TABLESPACES
*(INSTALL_SYSOPR/CURRENT_USER/USER)
VUM020 QUIESUSR INSTALL_SYSOPR
*VUM020 LINE TO DUPLICATE FOR OTHER DB2 SUBSYSTEMS
YES
A quiesce point is to be taken at execution time
unless keyword QUIESCECAT NO was specified
in the SYSIN of HPU.
NO
A quiesce point is NOT to be taken at execution
time unless keyword QUIESCECAT YES was
specified in the SYSIN of HPU.
FORCE
A quiesce point is ALWAYS to be taken at
execution time, even if keyword QUIESCECAT
NO was specified in the SYSIN of HPU.
OFF
A quiesce point is NEVER to be taken at
execution time, even if keyword QUIESCECAT
YES was specified in the SYSIN of HPU.
Default: NO if this variable is blanked out
You can leave the HPU parameters as they are in Table 7-9, or you can customize them
based on your installation’s requirements. The JCL portion is reported in Example 7-8.
NO
SELECT statements not supported by HPU will
not be processed by DB2.
YES
SELECT statements not supported by HPU will
be processed by DB2.
Default: YES
NO
Tables of the table space are not to be locked.
YES
Tables of the table space are to be locked.
Default: NO
NO
The table space is not to be quiesced.
YES
The table space is to be quiesced.
Default: NO
OFF
The null indicator is not present in the output data
set.hhhh
The first two digits (one hexadecimal character)
represent the null indicator for a null column. The
last two digits (one hexadecimal character)
represent the null indicator for a not null column.
TRAIL
The sign will be placed after the numeric
value.(TRAIL is ignored for
floating point numbers.)
ANY
The product is to decide whether parallelism will
be used.
Default: ANY
Default: BEFORE
ASCII
Indicates that the unloaded data must be in ASCII
format.HPU uses the subsystem’s ASCII CCSID,
unless overridden by specifying the CCSID
option.
ASIS
Indicates that the data is unloaded in its original
format.If the specification for the underlying table
space cannot be determined (for example, if the
data is processed by DB2), the CCSID returned
by a standard prepare statement in SQLDA is
used. You can also override ASIS by specifying
the CCSID keyword.
Specifying ASIS does not mean that no
conversion is necessary. Conversion may still be
required in some situations.
EBCDIC
Indicates that the data is unloaded in EBCDIC
format.HPU uses the subsystem’s EBCDIC
CCSID, unless you override it by specifying the
CCSID keyword.
UNICODE
Indicates that the data is unloaded in UNICODE
format.HPU uses the subsystem’s UNICODE
CCSID, unless you override it by specifying the
CCSID option.
Default: EBCDIC
Default:4
VUX101 to VUX105,VUX111,VUX112 Specify the job parameters for the JCL that
creates the plan for the utilities (INZBIND JCL) as
well as the SYSOUT CLASSes of SYSTSPRT
and SYSPRINT.
VUX141 to VUX145,VUX151 Specify the job parameters for the JCL that
customizes the Load modules with the name of
the HPU PARMLIB as well as the SYSOUT
CLASS of SYSPRINT.
Note that you do not have to input all the parameters that appear in the job, you only need to
change those values which the default is different from the value that you want. After you
finish inputting the parameters, record the changes you made and then save the data.
INZRSAVE in the library created in “Step 1: Allocating the INZRSAVE library” on page 126.
This member is used by the installation process when installing a new version of the product.
Note: Be aware that execution of the INZT02 procedure will override any manually
customized member that is supposed to be created by this procedure.
For more information, see “Step 3: Editing the INZTDSN member” on page 128.
The display panel in Figure 7-4 will appear when you run the INZADZBI. Press Enter to
confirm the new command HPU.
When INZADBI completes successfully, a new line - HPU, will be added to the DB2 tools
Launchpad.
Messages will be displayed to inform you about the progress of the CLIST run. There will be
requested actions along the duration of the run. These actions needs to be performed to
continue the installation. After the successful completion of the CLIST run you start HPU
interactively using the DB2 Admin tool. An example to run a CLIST program is in Figure 7-5.
This is inside the P.3.4 panel
Proceed as follows:
1. Review the contents of member INZBIND in the SINZSAMP library to verify that the JCL
reflects your environment.If you need to make changes, proceed to step 4.
2. Submit member INZBIND.
3. Check for correct execution.
4. If you have a problem with the BIND command or the GRANT statement, do not directly
modify this member; instead, correct the invalid values in the INZTVAR member and
re-execute the INZT02 procedure (see “Step 4.Editing the INZTVAR member” and “Step 5.
Executing the INZT02 procedure’.)
Important: If you encounter an error in the INZBIND jcl (RC > 0). Do not edit this member
directly. Instead change the INZTVAR member then rerun the INZT02.
Proceed as follows:
1. Review the contents of member INZPARM in the SINZSAMP library to verify that the JCL
reflects your environment. If you need to make changes, proceed to step 4.
2. Submit member INZPARM.
3. Check for correct execution.
4. If you have a problem with execution of this job, do not directly modify this member;
instead, correct the invalid values in the INZTVAR member and re-execute the INZT02
procedure (see “Step 4: Editing the INZTVAR member” on page 129 and “Step 5:
Executing the INZT02 procedure” on page 145.)
Important: The HPU PARMLIB consists of member INZUTIL. INZUTIL is located in the
library whose dsname is specified in variable INZPLIB in the INZTDSN member and in
variable VIZ007 in the INZTVAR member.
Member INZUTIL, which was generated by the INZT02 procedure, should not be
modified directly; instead, you should modify the INZTVAR member and re-execute the
INZT02 procedure (see “Step 4.Editing the INZTVAR member” and “Step 5.Executing
the INZT02 procedure”.)
Physical unload
In doing a physical unload, you just have to specify the table space name. You do not have to
code any SQL in the unload statement:
Reorg unload-only
Logical unload
A logical unload is done by coding one or more SELECT statements. Each SELECT
statement needs to have its own OUTDDN data set to handle the result set. Logical unload
enables you to filter the rows and columns to be unloaded, and specify the output format.
These are the file formats that can be created in a logical unload:
DSNTIAUL
HPU provides a simplified way to produce output identical to that produced by the
DSNTIAUL program. In this case, the SELECT statement can contain only a column
name, and no format conversion is available. As an option, you can generate output based
on a table other than the one you are unloading. This is done using the keyword LIKE.
When using LIKE, the selected column must be compatible with the like table.If any
conversion is required, it follows HPU format rules.
DELIMITED
A delimited file is characterized by delimited rows and character strings. To create this type
of output just specify what kind of character you want to be used as a delimiter. The output
can be ASCII or EBCDIC file.
VARIABLE
Specify FORMAT VARIABLE to indicate that the output data set must be compatible with
the DB2 LOAD data set. The default output data set is variable blocked (VB), but you can
specify another format (F, FB, or V) in the JCL. HPU determines the LRECL at run time
using the following rules:
a. Fixed and fixed blocked: the LRECL must be larger than or equal to the sum of the
lengths of the fields.
b. Variable: the LRECL must be larger than or equal to the sum of the lengths of the fields
plus 4.
Variable-length fields are counted using their maximum length, plus 2 bytes for the length
of the field.
You can specify the following options for formatting the variable columns:
– END
The characteristics and the sequence of fields in the generated data set correspond to
those in the SELECT statement. The fields generated in the data set are also typical of
those in DSNTIAUL format; the only differences are:
Columns in DATE, TIME, or TIMESTAMP have the format ISO, which means:
– DATE corresponds to format YYYY-MM-DD
– TIME corresponds to HH.MM.SS
– TIMESTAMP corresponds to YYYY-MM-DD-HH.MM.SS.NNNNNN
If a column accepts the nulls, the null indicator is generated in front of the field. This
indicator contains the value X ’FF’ if the field is null and X ’00’ if the value is usable. If the
last selected column is variable, the type of the default generated data set will be VB, and
USER
Specify FORMAT USER to indicate that you want the unloaded data to be formatted
according to the keywords specified in the user_block. You can change field attributes for
all selected columns, which means you can specify several keywords for each column,
according to the type of data the column contains.
The default values are determined by the values set in the options_block.
If all the fields unloaded are fixed, then the default RECFM is FB.If at least one output field
is variable, then the default RECFM is VB.
If the LRECL is not specified, HPU determines it at run time using the following rules:
– Fixed
The LRECL of the data set is equal to the sum of the maximum length of fields,
regardless of what was specified as the LRECL in the JCL.The output data set will be
in FB format.
– Variable and variable blocked
The LRECL of the data set is equal to the sum of the maximum length of fields plus
4,regardless of what was specified as the LRECL in the JCL.The output data set will be
in VB format.
You can customize every output column however you want.You can force the conversion
between type, change the date or time format, add or remove a length field, add or remove
a null indicator, justify the content left or right, select a padding character, select a delimiter
character for date and/or time, and so on.
You can use the HPU either by running a TSO batch job or by running it interactively using the
DB2 Administration tool or DB2 tools Launchpad. The data input can come from table spaces
or image copies. The output can be in different formats such as delimited, variable or
DSNTIAUL compatible. The HPU can also do the EBCDIC to ASCII conversion and
vice-versa.
Any SQL statement that requires more than one pass on the data to be processed will be
passed to the DB2 engine. One example is table joins. HPU opens the data set and reads
from the first page to the last page. If it needs to loop back in order to satisfy a query it will
pass the control to the DB2 engine for processing.
Example 7-11 The INZEXECU JCL sample for using the HPU
//PAOLOHPU JOB (999,POK),'DB2UNLOAD',CLASS=A,MSGCLASS=T,
// NOTIFY=&SYSUID,TIME=1440,REGION=0M,MSGLEVEL=(1,1)
//*
//***************************************************************
//* *
//* DB2 UNLOAD JCL *
//* *
//* IN THIS SAMPLE : *
/*
//SYSPRINT DD SYSOUT=*
//*
//********* DDNAMES USED BY THE SELECT STATEMENTS **********
//*
//UNLDDN1 DD DSN=PAOLOR2.MD.UNLD1,
// DISP=(NEW,DELETE,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(10,20),RLSE)
//UNLDDN2 DD DSN=PAOLOR2.MS.UNLD2,
// DISP=(NEW,DELETE,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(10,20),RLSE)
//LOADDDN1 DD DSN=PAOLOR2.MD.LOADA,
// DISP=(NEW,DELETE,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(10,20),RLSE)
In the batch job shown in Example 7-11, HPU executes the unload of two different tables
inside one tables space. There are two select statements here, one for each table, while the
unload is issued at table space level. In this example, the data is unloaded from the
DSNDB04.DEPT table space. This table space contains the EMP and DEPT tables. Two
different tables can be unloaded at the same time if they belong to the same tablespace. The
unloaded data is located in the specified OUTDDN. The OUTDDN points to another data set
specified by the UNLDDN1 and UNLDDN2. The UNLDDN1 and UNLDDN2 specify the data
set names where the table space is unloaded. They will contain the result set of the select
statement that corresponds to them. As shown, each select statement needs its own
OUTDDN. In this case, PAOLOR2.MD.UNLD1 and PAOLOR2.MS.UNLD2 are the data sets
that will receive the unloaded data from the EMP and DEPT table correspondingly. We have
chosen to have PAOLOR2.UNLD1 in variable format, and PAOLOR2.UNLD2 in DSNTIAUL
format.
The control program being executed by the job is the INZUTILB. The library where the
INZUTILB is in should be APF authorized. In our case, it is in INZ.V2R1M0.SINZLINK library
which we specified in the STEPLIB.
The PARM statement contains the DB2 subsystem name. The name can be either the name
of a DB2 subsystem inside a non data sharing environment, or the DB2 group attachment
name when processing inside a SYSPLEX data sharing environment. The name should
correspond to the value in VZD001of INZTVAR. In our example, we use the DB2 subsystem
name which is DB2G.
The unique identifier for your HPU job is specified in the second parameter of the PARM
equation. This is UID. You cannot use special characters in the UID. In our example, the UID
is DB2UNLOAD.
The reserved DD names allocated dynamically by HPU are shown in Table 7-11. You cannot
use these DDNAMES for other purpose.
SORT DDNAMEs HPU calls the SORT utility when you specify an
ORDER BY or an ORDER
CLUSTER.Thus,SORT DDNAMEs are allocated
dynamically.
There are also DDNAME in the HPU JCL the user needs to provide. These DDNAMES are
shown in the Table 7-12.
SYSPRINT DD name for the data set that receives the report
from execution of HPU.
The Unload block is the main block. It is where all other blocks are connected. A Select block,
a Global block, and/or an Options block can be connected to an Unload block. The Format
block can only be connected to a Select block. If your HPU statement does not have a Select
block then the Format block is not needed. The Options block can be connected to a Select
block, Global block, and the Unload block, but it cannot be connected to a Format block. The
Global block can contain an Options block. See Figure 7-7.
Unload block
The Unload block Example 7-12 is the main block of the HPU statement. All HPU statements
are required to have this block.
DB2
Specifies the processing to be performed for SELECT statements that are not supported
by HPU.
– YES
LOCK
Indicates whether or not HPU must lock the table space during the unload:
– YES
The table space is accessed in read-only mode during the execution of HPU.
– NO
The table space is processed without changing its access mode.
QUIESCE
Specifies whether or not to issue a QUIESCE against the table space before unloading it.
If the unload is against an image copy, this option is ignored.
– YES
The QUIESCE command is processed if the table space is not in COPY pending
status; otherwise, the table space is stopped and restarted.
– NO
The table space is processed without QUIESCE.
QUIESCECAT
Specifies whether or not to issue a QUIESCE on the DB2 catalog’s table spaces before
unloading.The QUIESCE is done only once, prior to any catalog access, if at least one
unload requests it:
– YES
A QUIESCE is to be processed on the catalog tables.
– NO
No QUIESCE is to be processed on the catalog tables.
Global block
In this block you put the global options that you want for all of the output files. The options you
specify in the global block will be the default option for all the output files created by the Select
statements in SYSIN. However, the options specified in the Unload block takes precedence
over the Global block. Hence, these values will be overridden by the options you specify for
each column or table in the Unload block.
Select block
In this block, you specify the table, column name or column number of the data that you want
to unload. The options available in the Select block is in Example 7-14.
SELECT
The use of the select clause statement in this block is the same as the DB2 SQL Select
clause. See DB2 SQL User’s Reference Guide for further information.
The select statement in this block includes these clauses:
– Where clause
– Order by
ORIGINOBID
This keyword must be specified in conjunction with the COPYDDN statement.It is used
when the OBID table in the image copy is not the same as the OBID read in the
catalog.This can happen, for example, for an image copy of a table that was dropped and
then recreated with a new
OBID
If the source data is an image copy, use this keyword to specify the OBID of the rows to be
processed in this image copy.
– integer
If the image copy file contains a unique table, the value 0 can be used instead of the OBID
of the table. If you specify the value 0, HPU processes the first OBID that is found in the
image copy.
– X ’hhhh’
hhhh is the hexadecimal value of the OBID of the table in the image copy.
OUTDDN outdd
Specifies the ddname of the sequential output data set containing the unloaded data.You
can specify up to 255 ddnames. outdd is the base ddname of the output data set. If you
want HPU to perform processing in parallel for partitioned table spaces, code in your JCL
one outdd nnn statement for each partition (outdd 01 outdd 02 ...outdd nnn), where nnn is
a 2-to 4-digit sequential number that identifies a partition to be unloaded. During the
unload process data from each partition is directed to the corresponding ddname. If the
corresponding ddname is allocated, it is used for the given partition; otherwise, the base
ddname, if allocated, is used. For example:
UNLOAD TABLESPACE PART(1,2,4,5)SELECT *FROM Q.T OUTDDN(MYDD)
FORMAT DSNTIAUL
If MYDD,MYDD01,and MYDD0004 are allocated, then MYDD contains the rows from
partition 2 and 5,MYDD01 contains the rows from partition 1, and MYDD0004 contains the
rows from partition 4.
If you do not specify this parameter, then specify UNLDDN on the UNLOAD TABLESPACE
statement.
OUTMAXROWS n
Specifies the maximum number of rows, n to be extracted for this SELECT statement. If
you are processing a partitioned table space, the number n applies to each partition.
OUTFREQROWS n
Specifies the unload sampling frequency. One row every n rows will be written to the
OUTDDN data set.
OUTEXIT exitname
Specifies the name and the language of the exit that handles the rows during unload
processing.The exit must reside in an authorized library, and is loaded dynamically during
the execution.The library must be in either the LINKLIST, or in an authorized JOBLIB or
STEPLIB. For COBOL/2 and C, the STEPLIB, JOBLIB, or LINKLIST should also point to
the LE/370 runtime libraries.
– ASM
Assembler language
– C
C language
– COBOL2
COBOL/2 language
Default: ASM
EBCDIC/ASCII/UNICODE/ASIS
Specifies that the data is unloaded in EBCDIC, ASCII, or UNICODE format using the
CCSID of the installation or the specified CCSID.
– ASCII
CCSID
Specifies up to three coded character set identifiers (CCSIDs) for the unloaded data.The
first specifies the CCSID for SBCS data, the second specifies the CCSID for MIXED
DBCS data, and the third specifies the CCSID for DBCS data.If any of these are specified
as 0 or omitted, the CCSID of the corresponding data type is assumed to be the same as
the installation default CCSID.
CCSID can also be specified at the column level, in the user_block syntax.
Format block
In this block, you specify the format of the output data that will be produced by the HPU
statement, see Example 7-15. The Format block can only be attached to a Select block.
DELIMITED delimited_block
Use this keyword to specify that data is to be unloaded in DELIMITED format.For a
description of the delimited_block syntax, see “DELIMITED block”.
You have the following three options:
– SEP val
This keyword defines the separator character to be used in a FORMAT DELIMITED.
• val can be ’c’ or X ’hh’.
Default blank
– DELIM val
val can equal ’c’ or X’hh’.This option defines the delimiter character (there is no default
value.)
– NULL DELIM
This option defines whether the null values should be enclosed by the delimiter.
Char, varchar, graphic, and vargraphic columns are enclosed by the delimiter
character.Null columns are not enclosed by the delimiter character if DELIM val and NULL
DELIM are coded. All the other types of columns are enclosed by the separator character.
Columns in DATE, TIME, and TIMESTAMP have the format ISO, which means:
– DATE corresponds to format YYYY-MM-DD
– TIME corresponds to HH.MM.SS
– TIMESTAMP corresponds to YYYY-MM-DD-HH.MM.SS.NNNNNN
You can override the default DATE/TIME/TIMESTAMP format by specifying an
options_block at the SELECT level.Only a SELECT level options_block will be taken into
consideration for this format.
DSNTIAUL dsntiaul_block
Use this keyword to specify that data is to be unloaded in the same format as is produced
by the DSNTIAUL program.
USER user_block
Use this keyword to specify that data is to be unloaded as defined by the user. You can
specify the format of a specific column using a user_block. Specify FORMAT USER to
indicate that you want the unloaded data to be formatted according to the keywords
specified in the user_block.You can change field attributes for all selected columns, which
means you can specify several keywords for each column, according to the type of data
the column contains.
The default values are determined by the values set in the options_block. If all the fields
unloaded are fixed, then the default RECFM is FB. If at least one output field is variable,
then the default RECFM is VB.
If the LRECL is not specified, HPU determines it at run time using the following rules:
Important: When you pad a character field and also do a conversion from EBCDIC to
ASCII or vice-versa in one HPU job. The output file will be converted first before it is
padded by the value you specify. So you will have a field with EBCDIC characters but with
ASCII padding or a field with ASCII characters with EBCIDC padding depending on the
conversion you are doing. So it is not recommended that you pad your characters and do
the code page conversion at the same time in one HPU statement.
One way to do it is by padding your character fields in your HPU statement. When you
already have the output file do the code page conversion through FTP.
– DELIM literal
VARIABLE variable_block
Use this keyword to specify that data is to be unloaded in a format that is compatible with
the DB2 LOAD data set.
You can specify the following options for formatting the variable columns:
– END
The characteristics and the sequence of fields in the generated data set correspond to
those in the SELECT statement. The fields generated in the data set are also typical of
those in DSNTIAUL format; the only differences are:
Columns in DATE, TIME, or TIMESTAMP have the format ISO, which means:
• DATE corresponds to format YYYY-MM-DD
• TIME corresponds to HH.MM.SS
• TIMESTAMP corresponds to YYYY-MM-DD-HH.MM.SS.NNNNNN
If a column accepts the nulls, the null indicator is generated in front of the field.This
indicator contains the value X ’FF’ if the field is null and X ’00’ if the value is usable.
If the last selected column is variable, the type of the default generated data set will be VB,
and this last column will be written only on its effective length; the two length bytes are
placed before the column.
You can override the default DATE/TIME/TIMESTAMP format by specifying an
options_block at the SELECT level.Only a SELECT level options_block will be taken into
consideration for this format.
– ALL
The only difference between this format and the END format is that all the variable
columns are written using their actual length.
– LIKE table-name
The use of FORMAT VARIABLE with a table name is the same as for FORMAT DSNTIAUL
(described on page “DSNTIAUL block”), and the differences described above are still
valid.
LOADDDN loaddd
Use this keyword if you want HPU to create a command data set for the Load utility.
– loaddd
Specifies the name of the DD statement describing the command data set.The
corresponding DD statement must be present in the execution JCL.This data set contains
the necessary commands for loading a sequential data set using the DB2 LOAD utility.
LOADOPT
This keyword enables you to modify the options of the DB2 LOAD command.Use this
keyword to specify the options that you want HPU place in the LOAD SYSIN that is
created during the unload process.
– tableoptions
Options for the table space
– partoptions
Options for the partition
UNLDDN unldd
Indicates that a physical unload of the table space is to be performed, and specifies the
ddname of the output data set.
– unldd
This is the base ddname of the output data set. If you want HPU to perform processing in
parallel for partitioned table spaces, code in your JCL one unldd nnn statement for each
partition (unldd 01 unldd 02 ...unldd nnn , where nnn is a 2-to 4-digit sequential number
that identifies a partition to be unloaded. During the unload process, data from each
partition is directed to the corresponding ddname.
If the corresponding ddname is allocated, it is used for the given partition; otherwise, the
base ddname, if allocated, is used. For example:
UNLOAD TABLESPACE PART(1,2,4,5)UNLDDN(MYDD)FORMAT DSNTIAUL
If MYDD,MYDD01,and MYDD0004 are allocated, then MYDD contains the rows from
partition 2 and 5,MYDD01 contains the rows from partition 1, and MYDD0004 contains the
rows from partition 4.
If you do not specify this parameter, specify OUTDDN on the SELECT statement.
The format of this data set is similar to the format when a DB2 REORG UNLOAD ONLY is
done.
UNLMAXROWS n
Specifies the maximum number of rows to unload for a physical unload.If the unload
involves a partitioned table space, which is treated partition by partition, then the limit
applies to each partition.The variable n must be an integer.
UNLFREQROWS n
Specifies the unload sampling frequency for a physical unload.One row of every n rows
will be written to the UNLDDN data set.The variable n must be an integer.
Options block
The options_block enables you to specify the default conversions that will be used with the
SELECT statement. This block can be used in the global_block, the unload_block, and the
select_block.
Options specified in a global_block or unload_block are only applicable to the USER format,
except LOADOPT. The value of the LOADOPT is created by merging values specified in the
parmlib, the global_block, the unload_block, and the select_block.However,LOADOPT is also
specified in the FORMAT specification, then it is used as is (no merge with previous levels.)
Options block, see Example 7-17.
NULL
Indicates whether the null indicator is generated in the output data set.This keyword has
meaning only for the USER format.It also can be specified in the SELECT statement in the
FORMAT USER syntax.
– val1 Value of the null indicator when the column value is NULL.
– val1 can be specified in character (’C’) or hexadecimal (X'hh').
– val2 Value of the null indicator when the column value is NOT NULL.
– val2 can be specified in character (’C’) or hexadecimal (X'hh').
– OFF No null indicator is generated.
DATE DATE_x
Specifies the default output format for the DATE columns.Specify DATE_x where x can be
any uppercase letter from A through P. The formats for each choice are as follows:
– DATE_A format MM-DD-YYYY
– DATE_B format MM-DD-YY
– DATE_C format YYYY-MM-DD
– DATE_D format YY-MM-DD
– DATE_E format DD-MM-YYYY
– DATE_F format DD-MM-YY
– DATE_G format YYYY-DDD
– DATE_H format YY-DDD
– DATE_I format MMDDYYYY
– DATE_J format MMDDYY
– DATE_K format YYYYMMDD
– DATE_L format YYMMDD
– DATE_M format DDMMYYYY
– DATE_N format DDMMYY
– DATE_O format YYYYDDD
– DATE_P format YYDDD
DATEDELIM literal
Specifies the default delimiter to be used in external date representation. Val must be one
character (and one byte long, regardless of the literal CCSID.)
TIME TIME_x
Specifies the default conversion for time representation.Specify TIME_x where x can be
any uppercase letter from A through E. The result of each choice is as follows:
– TIME_A format HH.MM.SS
– TIME_B format HH.MM
– TIME_C format HH.MM AM
– TIME_D format HHMMSS
– TIME_E format HHMM
TIMESTAMP TIMESTAMP_x
Specifies the default conversion for the TIMESTAMP columns.Specify TIMESTAMP
TIMESTAMP_x, where x can be an uppercase letter from A through G.The result of each
choice is as follows:
– TIMESTAMP_A format YYYY-MM-DD-HH.MM.SS
– TIMESTAMP_B format YYYY-MM-DD-HH.MM.SS.NNNNNN
– TIMESTAMP_C format YYYYMMDDHHMMSS
– TIMESTAMP_D format YYMMDDHHMMSS
– TIMESTAMP_E format YYYYMMDDHHMMSSNNNNNN
– TIMESTAMP_F format YYMMDDHHMMSSNNNNNN
– TIMESTAMP_G format YYYY-MM-DD HH:MM:SS.NNN
For DATE, TIME, and TIMESTAMP columns:
The values DATE_C, TIME_A, and TIMESTAMP_B are used to unload the DATE,TIME,
and TIMESTAMP columns, unless other values are specified for the TYPE parameter
within the FORMAT USER block
Default values in the OPTIONS block
Variables VUU015/ULDATE,VUU016/ULTIME, or VUU017/ULTMSP at installation or
during the customization process.
LOADOPT
For this keyword, see the LOADOPT description in the Format block.
LENGTHBYTE
Specifies whether the 2 length bytes for variable-length columns should be written to the
output data set.
– YES
The two length bytes should be written.
– NO
The two length bytes should not be written.
Default: LENGTHBYTE YES
LENGTH
Specifies whether the real or maximum length is to be used for fields of variable length.
– REAL
The length of the field is not to change (value of the two length bytes.)
– MAX
The output field is to be padded to its maximum length with binary zeros.
This keyword is only useful for variable-length fields.
Default: LENGTH REAL
NULLID
Specifies whether a null indicator byte is to be created preceding an output field.This
keyword is has meaning only for the USER format.It can also be specified in the SELECT
statement in the FORMAT USER syntax.
NULLPOS
Specifies the position of the NULL indicator.This keyword is has meaning only for the
USER format. This option is only available in the OPTION BLOCK.
– BEFORE
Position the null indicator before the data field.
– AFTER
Position the null indicator after the data field.
Example 7-18 Sample JCL to unload to an ASCII file with variable format
//PAOLOHPU JOB (999,POK),'DB2UNLOAD',CLASS=A,MSGCLASS=T,
// NOTIFY=&SYSUID,TIME=1440,REGION=0M,MSGLEVEL=(1,1)
//*
//***************************************************************
//* HP UNLOAD ASCII
//***************************************************************
//*
//STEP1 EXEC PGM=INZUTILB,REGION=0M,DYNAMNBR=99,
// PARM='DB2G,DB2UNLOAD'
//STEPLIB DD DSN=INZ.V2R1M0.SINZLINK,DISP=SHR
// DD DSN=DB2V710G.SDSNEXIT,DISP=SHR
// DD DSN=DB2G7.SDSNLOAD,DISP=SHR
//*
//SYSIN DD *
UNLOAD TABLESPACE DSNDB04.DEPT
DB2 YES
QUIESCE YES QUIESCECAT YES
OPTIONS DATE DATE_A
Example 7-22 Selectively unloading partitions 1,2 and 4 in a partitioned table space
UNLOAD TABLESPACE DB_DB04.TS_PROD1 PART (1,2,4)
SELECT * FROM SANCHEZ1.DEPT01
OUTDDN (OUTDD1)
FORMAT VARIABLE END
UNLOADTABLESPACE DSNDB04.DEPT01
Example 7-26 Unloading limited number of rows and calling a user exit
UNLOADTABLESPACE DSNDB04.TS_PROD01
SELECT * FROM SANCHEZ1.DEPT01
OUTDDN (MYOUT)OUTMAXROWS 150
OUTFREQROWS 10
OUTEXIT CBLEXIT COBOL2
FORMAT VARIABLE END
In Example 7-28 you will find syntax for these three alternatives.
//COPYDD DD SYSOUT=*
//SYSIN DD *
UNLOAD TABLESPACE DSNDB04.DEPT1ZN9
COPYDDN -1
//COPYDD DD SYSOUT=*
//SYSIN DD *
UNLOAD TABLESPACE DSNDB04.DEPT1ZN9
COPYDDN COPYDD
//COPYDD DD DSN=PAOLOR2.COPY0005.DEPT1ZN9,DISP=SHR
Older full image copies that the youngest can be referred in two ways:
Related to the last (-1) with negative integer (-n)
Data set name
In Example 7-29 you will find syntax to find the third youngest copy for these two alternatives.
//COPYDD DD SYSOUT=*
//SYSIN DD *
UNLOAD TABLESPACE DSNDB04.DEPT1ZN9
COPYDDN COPYDD
//COPYDD DD DSN=PAOLOR2.COPY0004.DEPT1ZN9,DISP=SHR
Note: If you are using the negative integer or the LAST_IC key word, HPU always in the
job report will verify which data set name was used.
//COPYDD DD DSN=PAOLOR2.COPYI002.DEPT1ZN9,DISP=SHR
USERID - PAOLOR3
Enter SESSION MANAGER Mode ===> NO (YES or NO) TIME - 13:04
Enter:
DB2 system name ===>
Step 4: Select the table or table space that you want to unload
When you are already in the DB2 Administration system catalog panel enter T at the options
prompt line. This will bring you to the DB2 Administration tables, views, and aliases panel. In
this panel yo can select the table that yo want to unload.
If you want a physical unload of a table space where you unload the entire table space with all
the tables in it you should choose the S option from the DB2 Administration system catalog
panel as shown in Figure 7-11. This will bring you to the DB2 Administration table space
panel. In that panel you can select the table space that you want to unload.
More: +
Options: DB2 System: DB2G
V - Volumes DB2 SQL ID: PAOLOR3
G - Storage groups GA - Authorizations to storage groups
D - Databases DA - Authorizations to databases
S - Table spaces SA - Authorizations to tables spaces
T - Tables, views, and aliases TA - Authorizations to tables and views
X - Indexes
C - Columns CA - Authorizations to columns
Y - Synonyms
P - Plans PA - Authorizations to plans
K - Packages KA - Authorizations to packages
L - Collections LA - Authorizations to collections
M - DBRMs RA - Authorizations to resources
Enter standard selection criteria (An SQL LIKE operator will be used):
Name ===> Grantor ===>
Owner ===> Grantee ===>
In D/L/H ===> Switch Catalog Copy ===> N (N/S/C)
And/or other selection criteria (option xC shows you columns for option x)
Column ===> Operator ===> Value ===>
On the other hand, you can perform a logical unload by using the DB2 Administration tables,
views and aliases menu panel. In this option, you can download tables or views and have an
SQL SELECT statement to qualify rows and columns in the unload data. You can enter that
panel by selecting the option T on the DB2 system catalog panel. See Figure 7-12.
More: +
Options: DB2 System: DB2G
V - Volumes DB2 SQL ID: PAOLOR3
G - Storage groups GA - Authorizations to storage groups
D - Databases DA - Authorizations to databases
S - Table spaces SA - Authorizations to tables spaces
T - Tables, views, and aliases TA - Authorizations to tables and views
X - Indexes
C - Columns CA - Authorizations to columns
Y - Synonyms
P - Plans PA - Authorizations to plans
K - Packages KA - Authorizations to packages
L - Collections LA - Authorizations to collections
M - DBRMs RA - Authorizations to resources
Enter standard selection criteria (An SQL LIKE operator will be used):
Name ===> Grantor ===>
Owner ===> Grantee ===>
In D/L/H ===> Switch Catalog Copy ===> N (N/S/C)
And/or other selection criteria (option xC shows you columns for option x)
Column ===> Operator ===> Value ===>
Figure 7-13 The DB2 Administration tables, views, and aliases panel — Option HPU
You can also enter the HPU line command on the DB2 Administration tables spaces panel. Put
the command on the Select column corresponding to the table space that you want to unload.
See Figure 7-14.
DB2 Admin ------------------ DB2G Table Spaces --------- Row 200 to 212 of 407
Command ===> Scroll ===> PAGE
Figure 7-14 The DB2 Administration table spaces panel — Option HPU
This panel allows you to select the output format. You can select from DSNTIAUL, delimited
file, non-delimited file, variable and user format. In our example, we have chosen the
delimited format. Our row delimiter is a semicolon(;) and our character delimiter is a double
quote (“). The table name chosen here is PAOLOR7.DEPT. Our table will be unloaded in an
EBCDIC file format because this is the default value that we specified in the INZTVAR
member.
If you choose the DSNTIAUL format it is necessary to fill-up the LOADddn command options.
Choosing the DELIMITED format will give you the option to fill-up the SEP and DELIM
parameters.
You can choose the file scheme whether EBCDIC to ASCII. You will need this transformation
if you will move your data from mainframe to distributed environment. Mainframe computers
use EBCDIC characters while machines in distributed platform use ASCII characters.
OUTMAXROWS ===>
OUTFREQROWS ===>
The characters used in different languages requires different code pages. For example, if the
table you are unloading uses double byte Japanese characters, you need to specify in the
DBCS option the appropriate code page number, so that the Japanese characters can be
handled properly in the unloaded table. A list of the CCSID codes that you can use is in the
appendix.
After selecting the format of the output file, you can select the columns that you want to
download by going to the COLUMNS command option box and pressing Enter. You can
remove any column by typing D or you can arrange the order of the columns by entering the
numbers on the Pos in Select column on the panel.
You can also go to the WHERE command option to enter a condition to qualify each row in
the select statement of the unload. When you go to this panel you have to type the conditions
that will be in the Where clause of your Select statement.
The COLUMNS and the WHERE options are not required to complete the JCL that will be
generated by the interactive tool. You can skip these and proceed the OUTDDN command
option. The OUTddn is where you enter the output data set that will be used. See Figure 7-18.
Important: The FORMAT and OUTDDN are the only required command options that
needs to be filled-up. The other option boxes, like COLUMNS, WHERE, ORDRER BY are
not required to be filled-up if you are going to unload the entire table.
You do not need to fill-up the Select-columns panel if you are going to unload all the columns
from the table.
You can enter the data set name that will be used to contain the unload data as shown in
Figure 7-18. This panel is required to be filled-up for all of the command options. After typing
the data set name press Enter.
In Figure 7-19, we are using a data set that does not yet exist in the DASD with
DISP=(NEW,CATLG,DELETE).
The JCL generated by the HPU interactive tool is in Example 7-31. This job will produce a
delimited file in EBCDIC file format. All of the contents of the DEPT table will be unloaded to
PAOLOR3.MD.UNLOAD.ASCDATA1 data set.
SELECT *
FROM
PAOLOR7 . DEPT
OUTDDN ( O11 )
FORMAT DELIMITED
SEP ';'
DELIM '"'
NULL DELIM
/*
Successful execution of the unload will result in return code equal to 0 (RC=0). See
Figure 7-23 for a sample outlist of a successful unload. A return code of 4 means there are
warnings on the unload operation. Look for the warning messages in the outlist. If it the
warning is tolerable then you can consider the unload successful. Ask your system
programmer about the warning messages. Any return code greater than 4 (RC=4) is
considered unsuccessful.
You can exit the HPU panel by pressing F3 several times until you reach the ISPF panels. You
can view the output file on the Data set list utility panel (P.3.4) of ISPF. In Figure 7-24 the
example is for a delimited EBCDIC file.
If you will move the data to a DB2 table in a distributed platform (UNIX, Windows, Linux) you
need to transform your file to ASCII format. But if you plan to move your data to another
mainframe DB2 table then you can leave it as an EBCDIC file.
Both sets of measurements were preceded by RUNSTATS execution and were run on a G7
zSeries engine with z/OS 1.3.
Table 7-13 shows the CPU and elapsed times of the executions of HPU and Unload for a
table with one index. From these results we can observe that:
There is no significant difference in elapsed time of HPU2.1 and DB2 V7 Unload.
HPU2.1 takes two to four times less CPU time when most rows in a table are to be
unloaded, with or without predicates.
HPU2.1 takes 20% more CPU time when the number of rows to be unloaded is small with
good filtering predicates.
Other measurements have shown that there is no difference as more indexes are added.
7.9 Considerations
The HPU for z/OS was created to provide an alternative to unload data from DB2 for z/OS
tables. The file format options in the output data allows it to be loaded to other tables in the
DB2 for z/OS database or across distributed platforms, using the ASCII and DELIMITED
format. The main difference of HPU is that it performs a tablespace unload by directly
accessing the data from the VSAM clusters using the VSAM buffering capability. Even though
HPU can execute the unload directly from the VSAM clusters, it still needs DB2 to be up and
running, in order to access the catalog and resolve all the object definitions.
The parallel execution of the select statements makes efficient use of each I/O operation.
Each row retrieved is offered to all select statements in the HPU job. It does not have to go
back to the same row in the table even if a different Select statement requires this row.
Performance tests on the HPU shows comparable performance to DB2 Unload utility in terms
of elapsed time. HPU takes less CPU time in execution, and also provides you with more
versatility because you can use the full SQL select statement to select the rows and columns
that you want to be unloaded.
HPU can directly process all types of SQL statements, but any SQL which cannot be resolved
by processing the data with just one pass, will be given back to DB2 for execution. For
example, HPU cannot directly perform a table JOIN or any column function. Hence, if at all
possible, you could try to simplify the SQL statement that you use in the HPU statement, so
that it can be performed by HPU without calling the DB2 engine. This will save you CPU time.
Whether or not HPU uses DB2 to access the rows from the table is transparent to the user if
the option DB2 has been set to YES.
You can also force the use of DB2 using the FORCE parameter when you know that the result
set is very small, and DB2 can take advantage of the filtering effect.
It is also highly recommended to specify QUIESCE YES and QUIESCECAT YES. This will
create a consistency point in the database and make sure that structure changes (such as
those reflecting table views used for unloading) are implemented. The buffer pools will be
flushed and data will be written on disk. If this option is not specified, you could have some
updates on your table that will not be included in the output data. A new option can eliminate
the need for QUIESCECAT by reading the DB2 catalog with SQL rather than the VSAM
structures.
The output file of the HPU can only be moved across different platforms through FTP or other
file transfers methods. You cannot take advantage of a Federated Database set-up where you
can move data from one table to another by just using nicknames. Moving data through HPU
is always a three step process:
1. unload data from source table,
2. FTP to the other machine,
3. load the data to the target table.
We have discussed the advantages and disadvantages of this tool. It is really up to the
database personnel to decide on its applicability and the related trade-offs.
The current version of HPU for MP is Version 2.1. It officially works with DB2 UDB Version 7.1
and above, though HPU tool needs FixPak 3 to work with DB2 UDB V8. This maintenance
level, equivalent to V1R2M3 was made available while this redbook was being written, hence
some of our results and recommendations are also applicable to DB2 UDB V8. During our
project we worked with both levels at modification 2 and 3. Informal tests did show that it also
works with DB2 UDB for UNIX V6.
HPU for MP can increase performance by circumventing the database manager. Instead of
accessing the database by issuing SQL commands against the DB2 database manager, as
typical database applications do, HPU itself translates the input SQL statement and directly
accesses the database object files. An unload from a backup image may be performed even if
the DB2 database manager is not running. Active DB2 database manager is needed to verify
that a user not belonging to the sysadm group does have authority needed to run the HPU
tool.
HPU can unload data to flat files, pipes, and tape devices. Delimited ASCII and IXF file
formats are supported. The user format option is intended to be used to create a file format
compatible with the positional ASCII (ASC) formats used by the other DB2 tools and utilities.
Creating multiple target files (location and maximum size can be specified) allows for better
file system management.
A partitioned database environment HPU with FixPak 3, offers the following features:
Data from all partitions can be unloaded to multiple target files.
The syntax allows you to unload, with a single command, on the machine where the
partition is, or to bring everything back to the machine you are launching HPU from. The
command OUTPUT(ON REMOTE HOST "/home/me/myfile") creates a file per partition on the
machine where the partition reside. Of course the path /home/me/ must exist on each
machine impacted by the unload.
A partitioned table can be unloaded into a single file.
The command OUTPUT(ON CURRENT HOST "/home/me/myfile") creates only the file myfile
on the machine you are running from, and will contain all the data of the unload. This is the
default, for compatibility reasons, while multiple files will offer better performance.
Note: The new option ON "mynamedhost" HOST behaves like ON CURRENT HOST, except
that the output file will be created on the specified host rather than the current host. A
restriction exists that the named host must be part of the UDB nodes.
A subset of table nodes can be unloaded by specifying command line options or through a
control file or both.
The OUTPUT command now supports the FOR PARTS() clauses. The appropriate
combination of these clauses allows you the needed flexibility.
For detailed information about the HPU, command line syntax, and control file syntax, please
consult IBM DB2 High Performance Unload for Multiplatforms User’s Guide.
Important: The install setup will fail if the system default permissions are less than
777 and the root super-user mask is different than 022.
If the automatic start does not work, from File Manager or Windows Explorer, locate your
CD-ROM drive and then double-click the setup.exe file.
Note: The Windows version must be installed by the Install Administrator only. The
installation is then available to all users with administration rights belonging to an
administrator group.
On NT 4.0,the hpuplug.zip file does not get copied into the sqllib \cc directory and renamed to
db2plug.zip. To work around this problem:
1. Copy the hpuplug.zip file from x:\Program Files \IBM \hpu \V2.1 \java and move it to
x:\Program Files \cc.
2. Rename hpuplug.zip to db2plug.zip.
If your HPU installation suddenly disappears, it is possible that the installation of another
product into the Control Center has overlaid the HPU plug-in. To fix this problem, you must
re-install the HPU plug-in.
Note: In case of a multi-node environment, HPU must be installed on all physical nodes.
You can only execute HPU on the catalog node.
Welcome page
The first page is the Welcome page. Click Next to continue the installation.
Note: At any time during the installation process, you can click Cancel to stop the
installation program or Back to return to the previous page.
The installation program installs HPU into various directories. For more information on these
directories, refer to page 11 of the IBM DB2 High Performance Unload for Multiplatforms User
Guide, SC27-1623-01.
Installation directories
The HPU installation program creates the following default product directory during the
installation (unless you specify a different directory):
On Windows:
\Program Files \IBM \hpu \V2.1
The following table lists the directories and significant files installed in your product directory
for all supported systems.
A typical db2hpu.cfg file is shown in the following example obtained with FixPak 2 level.
Lines beginning with a pound symbol (.#.) and empty lines are ignored. Each parameter is
defined on one line and that format is: keyword=value. There is no space between keyword
and the equal sign (.=.). There is also no space between the equal sign (.=.) and value.
pagesize
This parameter defines the size of the DB2 pages that will be unloaded. For each value of 4,
8, 16, or 32, a set of system resources will be locked. Your database should have a page size
of at least 32 KB. HPU will be faster if the pagesize parameter value is 4: 8: 16. This
parameter is ignored with FixPak 3.
bufsize
This is the value (8388608) of the parameter defining the default buffer size that is used when
writing the output file.The value is the actual number of bytes used for this buffer.
memsize
This parameter controls the default size of the memory buffer used between the reader and
writer co-processes when reading DB2 files. This value is the actual number of bytes. If the
input I/O is executed on the same device of the output (typical Windows demo situation) we
recommend a pretty small memsize (10-20 KB) and the largest bufsize possible (say 60 MB)
without causing paging. For a regular production system with more than one disk, a buff size
of 5-10 MB, and a memsize of 2-4 table spaces extents should be sufficient. These
recommendations are subject to change with the improvements that will be provided in the
db2dbdft
This parameter corresponds to the database name used by HPU when no database name is
given (command line option –d).
db2instance
The value that corresponds to the parameter is the instance name used by HPU when no
run-time value is given (command line option –i).
maxunloads
This parameter limits the number of concurrent threads that HPU will generate when
unloading DB2 files.HPU generates one thread by unload block.
maxsockets
This parameter is the number of connections the deamon will answer to concurrently. This
value is not user tunable and does not set a limit on the number of sockets that HPU
execution will open since they are HPU defined.
insthomes
This parameter provides the DB2 home directory path for all DB2 instances. At install time,
only one DB2 instance is granted with HPU, and if you need to grant more instances, you
must modify this parameter. For example, if you need to grant HPU with one default instance
of db2inst1 (instance home is /home/db2inst1) and another instance of db2inst2 (instance
home is /home/db2inst2), this parameter is:
insthomes=db2inst1:/home/db2inst1,db2inst2:/home/db2inst2
Restrictions
There are some restrictions on the complexity of SQL statements HPU can process.
Currently, when these are encountered, HPU uses the DB2 Export utility and the options are
not processed. Other restrictions are:
HPU cannot perform an unload from a DMS table space backup.
HPU does not support table joins.
HPU cannot evaluate select statements involving a WHERE clause.
HPU cannot select a subset of table columns.
Note that the HPU is an executable only, and it cannot be used through an application
programming interface.
In this example:
data is unloaded from the staff table in the sample database,
output is redirected to file staff.del,
default SQL statement selects all data in the table,
default data format is DEL, with column delimiter ‘,’ and char delimiter ‘”’,
data is unloaded from the database object files.
Settings needed to perform more complex unloads are defined through the unload
configuration file. The control file option is specified by ‘-f’. Other command line options can
be used in conjunction with it. To perform an unload reading the input values from file
db2hpu.config issue:
db2hpu -f db2hpu.config
HPU tool creates a single file for each LOB object it unloads. If a large number of records
containing LOB data needs to be exported both ‘lobs to’ and ‘lobfile’ can be specified. The
tool can unload up to 1000 lob objects for each basename specified by the lobfile parameter.
Multiple lob paths can be used to circumvent file system space limitations:
global connect to sample;
unload tablespace userspace1
select * from emp_resume;
output("emp_resume.ixf")
lob in ("lobs")
lobfile ("e_r1.lob", "e_r2.lob", "e_r3.lob", "e_r4.lob", "e_r5.lob", "e_r6.lob",
"e_r7.lob", "e_r8.lob", "e_r9.lob", "e_r10.lob")
format ixf;
In this example a maximum of 10000 records can be exported because 10 basenames for
LOB files are specified,
HPU will call the Export API if the select statement is too complex for its processing:
global connect to sample;
unload tablespace userspace1
select deptnumb,deptname from org where DEPTNUMB<40;
output("org.del")
format del;
In this example:
– A subset of columns is unloaded to a del file (due to the WHERE clause)
– As HPU cannot process this select statement, the Export utility is used
In this example:
Every tenth record in the employee table is unloaded into the output file.
First 5 records are skipped.
More examples of HPU use are distributed with the product. Please refer to Appendix A of the
IBM DB2 High Performance Unload for Multiplatforms Version 2, Release 1, SC27-1623-01.
Figure 8-2 The Output Options tab of the Fast Unload Notebook
If you need more information on the operation of the Control Center you can view the online
Help facility inside the control center.
Tables from the sample database were populated with randomly generated data. LOB objects
were stored in external files. Unless specified otherwise, Export was ran in the old lob mode,
creating a LOB file for each LOB object.
Non-partitioned sample database on Windows platform was used for the analysis
summarized in Table 8-4 on page 209. Table employee does not contain any LOB or LONG
columns and no indexes are defined on the table. Table emp_resume does contain a LOB
column, and a two dimensional primary key is defined on the table.
HPU outperforms Export in all scenarios. The difference is more significant when LOB fields
are present.
Warehouse 100 3 5
District 1000 1 3
Item 100,000 10 6
New_Order 899,991 52 9
The results have also been reported in the diagram in Figure 8-9.
These measurements show that HPU is better in elapsed time than DB2 Export. In this case
the difference is small for a small number of rows, but it reaches a ratio of five times at around
1 million rows and remains the same up to five million rows. Note that the tables used in this
set of measurements are not large and have rather narrow row length. They are significative
for an OLTP like environment. More measurements are planned from other sets of
applications.
960
840
720
600
Time in secs
DB2 Export
480
HPU
360
240
120
0
100 100,000 3,000,000
1000 899,991 5,000,000
# of rows exported
Part 4 Scenarios
s
In this part we describe some scenarios of moving data.
These are some factors you need to consider in choosing which tool is the best suited for your
data migration objectives.
Speed
Performance is one of the most important factors you need to consider when choosing a tool.
You need to know the length of time you have to complete the migration and the volume of
data you need to move. There are a lot of benchmark testing done by different vendors, but
you need to know that these tests are done in a controlled environment.
You need to understand the constraints and bottlenecks that you have in your system. Using
the fastest tool or most efficient tool is useless if your system has a network or I/O bottleneck.
Some tools are simply built for speed. But nothing is for free. There are always trade-offs
along the way. Versatility and control could be sacrificed to add a few mph on a tool. There are
tools now that no longer use DB2 to unload. These tools may provide better performance
because they directly access the physical file. However, they may lack the control and
versatility that comes from executing the SQL statements.
Concurrency
This is the ability of a tool to move data in a live environment. This means you do not have to
stop the database to load or unload the data. Furthermore, some tools have online
capabilities, giving other applications concurrent access to the data being processed.
This ability is essential for database shops where continuous availability of data is of primary
importance. For example, a bank’s ATM needs a 24x7 access to data of the depositors
accounts. A migration or back-up of a database needs to be concurrent to avoid down time.
Volume
The volume of data that can be transferred by a tool at a given time is an important factor that
should be considered. This factor matters more if you are moving an entire database or table
space involving terabytes of actual data.
Recovery
Recovery is the ability to go back to a consistent state and retrieve data if a database
operation fails. For example, if loading data to an active database fails, you need to be able to
recover by doing a rollback.
SQL capability
A tool that can execute SQL has a great advantage in versatility. The SQL select statement
enables the tools to process data selectively. You can choose which columns you want, join
tables, and have a condition for the rows you want to unload.
This is very useful if you intend to create a test database by using a subset of your data.
Sort capability
This is the capability of a tool to sort the data while doing the load or unload operation. If a
certain load or unload sequence is required and this capability is not present in the tool, you
need perform the data sorting separately, before performing the load. Without this capability
data is loaded in the same sequence as it appears in the input file.
Referential integrity
Referential integrity, in the RDBMS sense, is a restriction imposed by the DBMS in changes in
a table, so as to ensure that every column can only refer to a column that exists. The foreign
key of a table needs to access an existing primary key or unique key of another table. If this
concept is applied in moving data it would simply mean, moving a table (table A) whose
column refers to a column of another table (table B), requires that both of the tables (table A
and table B) need to be included in the data movement.
You need to know whether the tool you are using respects the referential integrity of your
data. The referential integrity of your database is implemented through the DBMS or through
the application that uses the data. If it is not implemented through the DBMS then you have to
manually monitor that all tables needed to preserve the referential integrity are being
downloaded together.
Security
Security in a data movement tool is its ability to control the access of people who can move or
copy data from a database or table. Security of a database also necessitates that even the
back-up files cannot be restored unless the person has the proper authority.
If your SYSCAT table space is an SMS type of table space, you should also consider updating
the database configuration parameters that are associated with the log files. You should
increase the values of logfilsiz, logprimary, and logsecond to prevent the space for these log
files from running out (normally SQL1704N with reason code 3). If this happens, increase the
log space parameters, and repeat the migration.
To provide compatibility of PC/IXF files among all products in the DB2 Family, the Export
utility creates files with numeric data in Intel format, and the Import utility expects it in this
format. However, take note that the PC/IXF format is different from the QMF IXF format that is
used in the mainframe. These two formats are not compatible with each other. You can find
documentation on their differences in the DB2 UDB Version 8 On-line documentation.
Depending on the hardware platform, DB2 products convert numeric values between Intel
and non-Intel formats (using byte reversal) during both Export and Import operations.
PC/IXF files cannot be loaded, but it can be imported into a partitioned database environment
using DB2 UDB V7.
Note: PC/IXF file format is different from the QMF/IXF format. These two file formats are
not compatible with each other.
DEL allows rows larger than 32 KB, while ASC does not.
ASCII files may have characteristics specific to the operating system on which they were
created. These characteristics are:
Row separator characters
– UNIX based text files use a line feed (LF) character.
– Non-UNIX based text files use a carriage return/line feed (CRLF) sequence.
End-of-file character
– UNIX based text files do not have an end-of-file character.
– Non-UNIX based text files have an end-of-file character (X’1A’).
When ASCII files are transferred from one operating system to another through FTP, changes
to the data can occur.
As a result of this consistency in internal formats, exported WSF files from DB2 products can
be used by Lotus 1-2-3 or Symphony running on a different platform. DB2 products can also
import WSF files that were created on different platforms. Transfer WSF files between
operating systems in binary (not text) mode.
Note: Do not use the WSF file format to transfer data between DB2 databases on different
platforms, because a loss of data can occur. Use the PC/IXF file format instead.
For details see DB2 UDB Data Movement Utility Guide and Reference Version 8, SC09-4830.
Unicode
A universal encoding scheme for written characters and text that enables the exchange of
data internationally. It provides a character set standard that can be used all over the world. It
uses a 16-bit encoding form that provides code points for more than 65,000 characters and
an extension called UTF-16 that allows for encoding as many as a million more characters. It
provides the ability to encode all characters used for the written languages of the world and
treats alphabetic characters, ideographic characters, and symbols equivalently, because it
specifies a numeric value and a name for each of its characters. It includes: punctuation
marks, mathematical symbols, technical symbols, geometric shapes, and dingbats. Three
encoding forms include the following:
With DB2 UDB Version 8, the Fixpack 2 code level will allow the creation of Unicode UTF-8
tables in any table space of a database of any other encoding.
A coded character set is a set of unambiguous rules that establishes a character set and the
one-to-one relationships between the characters of the set and their coded representations. It
is a character set in which each character is assigned a numeric code value.
Code page
A set of assignments of characters to code points. In EBCDIC, for example, 'A' is assigned
code point X'C1' and 'B' is assigned code point X'C2'. In Unicode, 'A' is assigned code point
"U+0041". Within a code page, each code point has only one specific meaning. A code point
is a unique bit pattern that represents a character. It is a numerical index or position in an
encoding table used for encoding characters.
Note:
1. The data to be exported or imported must comply with the size and data type
restrictions that are applicable to both databases.
2. To improve Import performance, you can use compound SQL. Specify the compound
file type modifier in the Import utility to group a specified number of SQL statements into
a block. This may reduce network overhead and improve response time.
Restrictions
With DB2 Connect, Export and Import operations must meet the following conditions:
The only file type supported by DB2 Connect is PC/IXF.
A target table with attributes that are compatible with the data must be created on the
target server before you can Import to it. The db2look utility can be used to get the
attributes of the source table. We discuss about generating the DDL for data transfer on
Chapter 9, “Getting ready for moving data” on page 213. Import through DB2 Connect
cannot create a table, because INSERT is the only supported mode.
Note: If you have DB2 UDB Enterprise Edition or Extended Enterprise Edition, DB2
Connect is already included in the package. It is installed automatically in your system
when you install the DB2 UDB.
Step 1
Logon to the ISPF panel using an ID with at least a Select privilege on the table or database
that you want to access. After logging on, go to the DB2 Administration Tool by entering ADM
on the main ISPF panel. See Figure 9-1.
USERID - PAOLOR3
Enter SESSION MANAGER Mode ===> NO (YES or NO) TIME - 13:04
Step 2
Go to the DB2 subsystem where your source tables or database is located. You can type S
corresponding to the DB2 subsystem name, or you can type it on the DB2 system name
prompt. See Figure 9-2.
Enter:
DB2 system name ===>
Step 3
Go to the DB2 system catalog panel by entering 1 on the Option prompt. See Figure 9-3.
Step 4
Choose the database object that you want to be the source of the DDL to be generated. If you
want a DDL for the table or view, choose T. If you want it for the whole database choose D. In
this example, we will generate the DDL of a group of tables, so we chose D. See Figure 9-4.
More: +
Options: DB2 System: DB2G
V - Volumes DB2 SQL ID: PAOLOR3
G - Storage groups GA - Authorizations to storage groups
D - Databases DA - Authorizations to databases
S - Table spaces SA - Authorizations to tables spaces
T - Tables, views, and aliases TA - Authorizations to tables and views
X - Indexes
C - Columns CA - Authorizations to columns
Y - Synonyms
P - Plans PA - Authorizations to plans
K - Packages KA - Authorizations to packages
L - Collections LA - Authorizations to collections
M - DBRMs RA - Authorizations to resources
Enter standard selection criteria (An SQL LIKE operator will be used):
Name ===> Grantor ===>
Owner ===> Grantee ===>
In D/L/H ===> Switch Catalog Copy ===> N (N/S/C)
And/or other selection criteria (option xC shows you columns for option x)
Column ===> Operator ===> Value ===>
Step 5
Select the database by entering GEN on the Select column corresponding to it. You can sort
the database list by entering SORT NAME on the Options prompt. See Figure 9-5.
Step 6
Check the options in this panel. Mark the database objects that you want to include in the
DDL by entering Y. See Figure 9-6.
New names/values for generated SQL: (leave blank to use current values)
Object owner . . . . . . : Run SQLID. . . . . . . . . :
Alloc TS size as . . . . : DEFINED (DEFINED, USED, or ALLOC)
Database name. . . . . . :
Storage group for TS . . : Storage group for IX . . . :
Target DB2 version . . . : (Current DB2 version: 710)
You can see the other options by pressing F8. You can leave most of the options in its default
value. You also have a choice of running the DDL through batch or running it through TSO.
You can specify this option in the Execution Mode prompt in Figure 9-9. You can chose
BATCH mode or TSO mode. If you chose batch mode a JCL job will be generated. You can
edit this job and submit it anytime you want. If you chose the TSO execution mode, the
command will be run automatically and the DDL will be re-created immediately.
Step 7
if you chose the BATCH execution mode, a JCL job will be generated as shown on the panel
(See Figure 9-8). You should review this job and submit. After you have submitted the job the
DDL will be re-created if there are no errors in the JCL.
Figure 9-8 This JCL panel will be displayed if you chose the BATCH execution mode.
If you chose the TSO execution mode, the DDL will be created immediately. There will be
some messages from the DDL generation that will be shown on your panel. Just press F3
until you reach the DDL statements as shown in Figure 9-9.
I
File Edit Edit_Settings Menu Utilities Compilers Test Help
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
EDIT SYS02324.T193403.RA000.PAOLOR3.R0104953 Columns 00001 00072
Command ===> Scroll ===> PAGE
000018 -- ADB2GEN: Generate DDL for Database DSNDB04 --
000019 -- --
000020 ------------------------------------------------------------------------
000021 --
000022 --
000023 ------------------------------------------------------------------------
000024 -- Database=DSNDB04 Stogroup=SYSDEFLT
000025 ------------------------------------------------------------------------
000026 --
000027 SET CURRENT SQLID='SYSIBM';
000028 --
000029 CREATE DATABASE DSNDB04
000030 BUFFERPOOL BP0
000031 INDEXBP BP0
000032 STOGROUP SYSDEFLT ;
000033 --
000034 SET CURRENT SQLID='PAOLOR5';
000035 --
000036 GRANT CREATETAB,CREATETS
Figure 9-9 The DDL statement of the database object in the DSNDB04 database
You are required at least a select privilege on the table of database before you can use this
tool. You do not need to connect to the database to execute, because this tool automatically
makes the database connection if you are not yet connected.
Syntax of db2look
The parts of the command outside the curly brackets are required. Those inside the curly
brackets are optional. The options are not positional. Hence, you can interchange the
placement of the letters representing the options.
-d DBname
Alias name of the database that is to be queried. DBname can be the name of a DB2 UDB for
UNIX, Windows, OS/2, or DB2 UDB for OS/390 database. If the DBname is a DB2 UDB for
OS/390 database, the db2look utility will extract the DDL and UPDATE statistics statements
for OS/390 objects. These DDL and UPDATE statistics statements are statements applicable
to a DB2 UDB database and not to a DB2 for OS/390 database. This is useful for users who
want to extract OS/390 objects and recreate them in a DB2 UDB database.
If DBname is an OS/390 database, then the db2look output is limited to the following:
Generate DDL for tables, indexes and views
Generate UPDATE statistics statements for Tables, columns, column distributions, and
indexes
-u Creator
Limits output to objects with this Creator ID. If option -a is specified, this parameter is ignored.
If neither -u nor -a is specified, the environment variable USER is used.
-z Schema name
Limits output to objects with this schema name.
Note:
This option removes all LaTeX and .tmp PostScript files.
Required non-IBM software: LaTeX, dvips.
The psfig.tex file must be in the LaTeX input path.
-g
Use a graph to show fetch page pairs for indices.
Note:
This option generates a filename.ps file, as well as the LaTeX file.
Required non-IBM software: Gnuplot.
The psfig.tex file must be in the LaTeX input path.
-a
When this option is specified the output is not limited to the objects created under a particular
creator ID. All objects created by all users are considered. For example, if this option is
specified with the -e option, DDL statements are extracted for all objects in the database. If
this option is specified with the -m option, UPDATE statistics statements are extracted for all
user created tables and indexes in the database.
Note: If neither -u nor -a is specified, the environment variable USER is used. On UNIX
based systems, this variable does not have to be explicitly set. On Windows NT, however,
there is no default value for the USER environment variable: on this platform, a user
variable in the SYSTEM variables must be set, or a set USER=<username>must be issued
for the session.
-h
Display help information. When this option is specified, all other options are ignored, and only
the help information is displayed.
-r
When this option is specified in conjunction with the -m option, db2look does not generate the
RUNSTATS command. The default action is to generate the RUNSTATS command. The -r
option is ignored if the -m option is not specified.
-c
When this option is specified in conjunction with the -m option, db2look does not generate
COMMIT, CONNECT and CONNECT RESET statements. The default action is to generate
these statements.
-t Tablename
Table name. Limits the output to a particular table.
-p
Use plain text format.
-e
Extract DDL statements for database objects. This option can be used in conjunction with the
-m option. DDL for the following database objects are extracted when using the -e option:
Tables
Views
Automatic Summary Tables (AST)
Aliases
Indexes
Triggers
User defined Distinct Types
Primary Key, RI, and CHECK constraints
User Defined Structured Types
User Defined Functions
User defined Methods
User defined Transforms
Federated objects (wrappers, sewers, nicknames, user mappings) with DB2 V8
Note: The DDL generated by db2look can be used to recreate user defined functions
successfully. However, the user source code that a particular user defined function
references (the EXTERNAL NAME clause, for example) must be available in order for
the user defined function to be usable.
-m
Generate the required UPDATE statements to replicate the statistics on tables, columns, and
indexes. The -p, -g, and -s options are ignored when the -m option is specified.
-l
If this option is specified, then the db2look utility will generate DDL for user defined table
spaces, nodegroups, and buffer pools. DDL for the following database objects is extracted
when using the -l option:
User defined table spaces
User defined nodegroups
User defined buffer pools
-x
If this option is specified, the db2look utility will generate authorization DDL (GRANT
statement, for example.)
-i
userid
-w password
Used with the -i option, this parameter allows the user to run db2look against a database that
resides on a remote system. The user ID and the password are used by db2look to logon to
the remote system.
Note: Only configuration parameters and registry variables that affect the DB2 query
optimizer are extracted.
Example 1
Generate the DDL statements for objects created by all users in the database SAMPWIN.
The db2look output is sent to file C:\DDLOUT.SQL as text file:
db2look -d sampwin -a -e -o c:\ddlout.sql
CONNECT TO SAMPWIN;
------------------------------------------------
-- DDL Statements for table "DB2INST1"."ORG"
------------------------------------------------
-- (there are other CREATE TABLE statements here truncated to shorten the example...)
COMMIT WORK;
CONNECT RESET;
TERMINATE;
Example 2
Generate the DDL statements for objects created by user DB2ADMIN in database
SAMPWIN. The db2look output is sent to file DDLOUT.SQL as text file:
db2look -d sampwin -u DB2ADMIN -e -o ddlout.sql
Example 3
Generate the UPDATE statements to replicate the statistics for the tables and indexes created
by user DB2ADMIN1 in database SAMPWIN. The output is sent to file ddlout.sql:
db2look -d sampwin -u DB2ADMIN -m -o ddlout.sql
CONNECT TO SAMPWIN;
---------------------------------------------
---------------------------------------------
UPDATE SYSSTAT.INDEXES
SET NLEAF=-1,
NLEVELS=-1,
FIRSTKEYCARD=-1,
FIRST2KEYCARD=-1,
FIRST3KEYCARD=-1,
FIRST4KEYCARD=-1,
FULLKEYCARD=-1,
CLUSTERFACTOR=-1,
CLUSTERRATIO=-1,
SEQUENTIAL_PAGES=-1,
DENSITY=-1
WHERE TABNAME = 'ORG' AND TABSCHEMA = 'DB2INST1';
UPDATE SYSSTAT.COLUMNS
SET COLCARD=-1,
NUMNULLS=-1
WHERE TABNAME = 'ORG' AND TABSCHEMA = 'DB2INST1';
UPDATE SYSSTAT.TABLES
SET CARD=-1,
NPAGES=-1,
FPAGES=-1,
OVERFLOW=-1
WHERE TABNAME = 'ORG' AND TABSCHEMA = 'DB2INST1';
UPDATE SYSSTAT.COLUMNS
SET COLCARD=-1,
NUMNULLS=-1,
--SUB_COUNT=-1,
COMMIT WORK;
-- Mimic functions
UPDATE SYSSTAT.FUNCTIONS
SET ios_per_invoc= -1.0,
insts_per_invoc= -1.0,
ios_per_argbyte= -1.0,
insts_per_argbyte= -1.0,
percent_argbytes= -1,
initial_ios= -1.0,
initial_insts= -1.0,
cardinality= -1.0;
COMMIT WORK;
CONNECT RESET;
TERMINATE;
Example 4
Generate both the DDL statements for the objects created by user DB2ADMIN and the
UPDATE statements to replicate the statistics on the tables and indexes created by the same
user. The db2look output is sent to file ddlout.sql:
db2look -d sampwin -u DB2ADMIN -e -m -o ddlout.sql
CONNECT TO SAMPWIN;
------------------------------------------------
-- DDL Statements for table "DB2INST1"."ORG"
------------------------------------------------
------------------------------------------------
-- DDL Statements for table "DB2INST1"."STAFF"
------------------------------------------------
---------------------------------------------
---------------------------------------------
UPDATE SYSSTAT.INDEXES
SET NLEAF=-1,
NLEVELS=-1,
FIRSTKEYCARD=-1,
FIRST2KEYCARD=-1,
FIRST3KEYCARD=-1,
FIRST4KEYCARD=-1,
FULLKEYCARD=-1,
CLUSTERFACTOR=-1,
CLUSTERRATIO=-1,
SEQUENTIAL_PAGES=-1,
DENSITY=-1
WHERE TABNAME = 'ORG' AND TABSCHEMA = 'DB2INST1';
UPDATE SYSSTAT.COLUMNS
SET COLCARD=-1,
NUMNULLS=-1
WHERE TABNAME = 'ORG' AND TABSCHEMA = 'DB2INST1';
UPDATE SYSSTAT.TABLES
SET CARD=-1,
NPAGES=-1,
FPAGES=-1,
OVERFLOW=-1
WHERE TABNAME = 'ORG' AND TABSCHEMA = 'DB2INST1';
COMMIT WORK;
COMMIT WORK;
-- Mimic functions
UPDATE SYSSTAT.FUNCTIONS
SET ios_per_invoc= -1.0,
COMMIT WORK;
CONNECT RESET;
TERMINATE;
After choosing the GENERATE DDL... from the menu box, a window will pop-up. You can
enter the database objects that you want to be included in your DDL by clicking the
check-box. Then click the Generate button. See Figure 9-13.
Figure 9-13 Generate DDL option box from the control panel.
You can look at the DB2 command that will be executed in the background by clicking the
Show Command button. This is optional but you can see from this screen the db2look
command being executed with the options that you selected using the check boxes. See
Figure 9-14.
After you click the Generate button on the options box. You will be prompted for your userid
and password. Remember that you need at least a select privilege on the catalog tables.
After entering the userid and password, you will see a message box saying that the job is
being run and you can see it in the Journal Window of the control center. Take note of the job
number. See Figure 9-15.
Go to the Journal window by clicking Tools in the menu bar and then Journal (Tools ->
Journal). When you are in the Journal window click the Job History button. All the jobs will
be shown in this window. Choose the job number that was specified in the message box. See
Figure 9-16.
After right-clicking on the line corresponding to the job number, a menu box will appear.
Chose the Show Results option. See Figure 9-17.
The DDL will be shown in the job output screen. See Figure 9-18.
For db2look
The db2look command can be called through the command prompt or through the DB2
Control Center. The DDL generated by this tool can be used without modification to create
database objects on another DB2 distributed platform. However, as mentioned above, you
need to do some minor modifications if you will use it to create DB2 database objects in a
z/OS platform.
We use these tools for moving data to a DB2 for z/OS target:
DB2 Cross Loader
DB2 Data Propagator
DB2 Unload and Load
DB2 HP Unload and Load
DB2 Export and Import
SQL Insert with subselect (in DB2 Version 8 only)
There are other set of tools that we can use to move data to and from a mainframe database,
such as DSNTIAUL and LOAD, but we are not going to write about them because there is
already an extensive literature about the use these tools. If you need instructions on how to
use them, you can refer to the DB2 for z/OS and OS/390 Version 7 Using the Utilities
Suite,SG24-6289-00, or the DB2 UDB for OS/390 and z/OS V7 Utility Guide and Reference,
SC26-9945-03.
In moving data across distributed and mainframe platforms, DB2 Connect and the Distributed
Data Facility (DDF) needs to be set-up in the system. See Appendix B, “DB2 connectivity” on
page 307 for more information. The only exception to this rule is when you move data through
FTP. Text files exported from a DB2 table in a distributed platform can be FTPed. These files
can be converted as sequential files with EBCDIC format in a mainframe. You can then use
these sequential files as input data to load tables in DB2 for z/OS. See Figure 10-1.
In DB2 Version 8 you can use Federated Database set-up in moving data across different
platforms or even different relational databases. See Appendix A, “Defining a Federated
Database” on page 299 for more information. In this scenarios, data can be moved from one
distributed database to a host database, or vice-versa by simply using SQL Insert and
subselect.
Important: When you move data, both the Data Definition Language (DDL) and the actual
data needs to be moved to the target system. The examples here show how to move actual
data. It is assumed that DDL has been transferred and tables have been created on the
target database. See Chapter 9., “Getting ready for moving data” on page 213 for
examples on extracting DDL and recreating it.
DB2 I
DPropR
Apply DDF DPropR
Target
Capture
table
Source Cross
Export
Cross DB2 utility
table Loader
Loader
with
with cursor CD DB2
cursor I,D
table
Source
table
HP Un- Unload Load
load tool utility utility Seq.
file
FTP D,
HP Un- (I)
Figure 10-1 Diagram of moving data from DB2 on distributed to DB2 for z/OS
The letters written on the arrows represents the formats that you can choose between:
A Positional (fixed) format (ASC)
D Delimited format (DEL)
I Integrated exchange format, PC version (IXF)
(I) We were not able to produce IXF from HPU for MP
Note: The broken line means that for the time being there is no utility or tool which
produces the positional format that LOAD on z/OS requires.
In this chapter, we use the Federated Database, DB2 Connect, and Distributed Data Facility
(DDF) to move data from distributed platforms to mainframe. In Figure 10-2, you can see that
we created a nickname for the PAOLOR7.DEPT and PAOLOR2.DEPT tables. Their
nicknames in the Federated Database system are DB2ADMIN.DEPT390S and
DB2ADMIN.DEPT390T, respectively. The DRDA WRAPPER enables the Federated
Database, which is created in the DB2 distributed database, to call tables on a DB2 on z/OS
database using nicknames. Take note that the table PAOLOR7.DEPT and the
PAOLOR2.DEPT tables are not created in the Federated Database. Nicknames are created in
the SAMPAIX8 database that point to tables in the DB2 for z/OS database.
The Cross Loader is simply a Load from a cursor. The cursor can be created through a Select
statement against a DB2 on distributed table. The result set will be loaded on a DB2 for z/OS
table.
In moving data within DB2 for z/OS databases, we used Unload and HPU for z/OS to unload
the data. We used Load utility on the mainframe to load the data to DB2 on z/OS tables.
Obviously, we did not used the Federated Database system and DB2 Connect in this
scenario.
nickname
sampaix8
db2g nickname
DB2INST2.
PAOLOR7. DBADMIN. DEPARTMENT
DEPT DEPT390S
DB2 insert with
PAOLOR2. Connect DBADMIN. subselect
DEPT DEPT390T
Cross
HPU Loader
DDF Export
File/
pipe
Unload Data Load Import
set
The numbers in Table 10-1 represent the section where the function and the example are
reported.
Cross Loader 10.2.1, “Using Cross Loader to move data from DB2 distributed to DB2 for z/OS”
on page 247 and 10.3.1, “Using Cross Loader to move data from/to DB2 for z/OS”
on page 251
Insert with 10.2.4, “SQL Insert with subselect in a Federated Database” on page 250 and
subselect 10.3.5, “SQL Insert with subselect in a Federated Database” on page 264
10.2.1 Using Cross Loader to move data from DB2 distributed to DB2 for z/OS
DB2 Cross Loader lets you transfer data from one database location to another in just one
job. The data is read from the source location with a dynamic SQL statement and loaded in a
table at the target location by the LOAD utility. The Cross Loader is actually an enhanced
function of the LOAD utility. It is the ability of the LOAD utility to populate a table using data in
a cursor you declared using EXEC SQL as input.
The advantage of this tool is its ease of use. You do not have to concern yourself with ASCII
to EBCDIC conversions, or what file format you are going to use. Data is extracted from one
table and loaded to another table in just one JCL step. There are no external files created in
the process. Data is just moved internally from the source table to the target table.
You would need to define the remote database in the DDF and CDB of the mainframe. The
remote database needs to be included in the SYSIBM.LOCATIONS, SYSIBM.IPNAMES, and
SYSIBM.USERNAMES. You can only use the three part name when the remote database is
defined in these tables.
To use DB2 Cross Loader, you need PTF UQ55541 for APAR PQ45268 and PTF UQ55542
for APAR PQ46759. These PTFs together with their PREREQ PTFs update DB2 V7 for
OS/390 to have the Cross Loader functionality.
Moving data from DB2 distributed to z/OS using DB2 Cross Loader
In this example, we move data from a table in DB2 distributed database to DB2 on mainframe.
We are using the three part name to access the table from the distributed platform
(SAMPAIX.DB2INST2.DEPARTMENT). Here, SAMPAIX8 is the database name, DB2INST2
Database objects
The database object used in this example are in Table 10-2.
Example 10-1 Cross Loader example of moving data from DB2 distributed to z/OS
//PAOLOR2A JOB (ACCOUNT),'PAOLOR2',NOTIFY=&SYSUID,USER=PAOLOR2
// EXEC PGM=DSNUTILB,PARM='DB2G,CRLOAD'
//STEPLIB DD DSN=DSN710.SDSNLOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT *
FROM SAMPAIX8.DB2INST2.DEPARTMENT
ENDEXEC
LOAD DATA
REPLACE
INCURSOR C1
INTO TABLE PAOLOR2.DEPT
You can Export a DB2 table in distributed platform into an IXF file then Import this file to an
existing table. Only IXF file format is supported. Only the Import INSERT option can be used.
The Import REPLACE and the Import CREATE option are not allowed. You need to have DB2
Connect running in your system. This however is automatically installed with DB2 Enterprise
Edition or DB2 Enterprise Extended Edition.
After the Federated Database is set-up, you can use the SQL Insert to write data to the target
z/OS database table. The SQL subselect is used to retrieve the data from the source DB2 on
distributed database table.
First, connect to the database in the client machine where the Federated Database is defined:
CONNECT TO SAMPAIX8
Then, issue the Insert with subselect command to transfer the data to the target:
INSERT INTO DB2ADMIN.DEPT390T SELECT * FROM DB2INST2.DEPARTMENT
You can also specify the columns that you want to retrieve in your Select statement. The
subselect is like a regular SQL Select statement. You can have a Where clause and scalar
functions in your Select statement as long as the result set matches the columns of your
target table.
Table 10-4 Database objects in moving data across DB2 for z/OS databases
Objects Object name
10.3.1 Using Cross Loader to move data from/to DB2 for z/OS
Cross Loader can also move data between two DB2 tables residing in z/OS.
Look at Example 10-2 to see an example of a DB2 Cross Loader job for moving data between
two mainframe DB2 tables.
Example 10-2 Cross Loader sample JCL moving from z/OS to z/OS
//PAOLCRLO JOB (999,POK),'DB2CRLOAD',CLASS=A,MSGCLASS=T,
// NOTIFY=&SYSUID,TIME=1440,REGION=0M,MSGLEVEL=(1,1)
//*
//***************************************************************
//* CROSS LOADER *
//***************************************************************
//*
//EXEC EXEC PGM=DSNUTILB,PARM='DB2G,CRLOAD'
//STEPLIB DD DSN=DB2G7.SDSNLOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUT1 DD DSN=PAOLOR3.LOAD.STEP1.SYSUT1,
// DISP=(MOD,DELETE,CATLG),
// UNIT=SYSDA,SPACE=(4000,(20,20),RLSE,,ROUND)
//SORTOUT DD DSN=PAOLOR3.LOAD.STEP1.SORTOUT,
// DISP=(MOD,DELETE,CATLG),
// UNIT=SYSDA,SPACE=(4000,(20,20),RLSE,,ROUND)
//SYSIN DD *
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT DEPTNO, DEPTNAME, MGRNO, LOCATION
FROM PAOLOR7.DEPT
ENDEXEC
LOAD DATA
INCURSOR C1
RESUME YES
INTO TABLE PAOLOR2.DEPT
//*
In the EXEC statement of the JCL, the UID (utility ID) of the first job step should be ‘UNLOAD’
and the UID of the second step is LOAD. The parameter ‘SYSTEM’ is the DB2 subsystem
name.
The SORTOUT data set in the LOAD step can be left blank because there is no index created
in the PAOLOR7.DEPT table during the LOAD. The data set
PAOLOR2.MD.UNLOAD.DATAVAR is the output data set in the Unload utility job step and it
will be the input data set in the Load utility job step. See Example 10-3.
The database object used in this example are in the table below. See Table 10-4 on
page 251. The Load and Unload option used in this example are explained below. See
Example 10-6.
Unload Options
Load Options
Look at Example 10-3 to see an example of a DB2 Unload and Load utility job for moving data
between two mainframe DB2 tables.
Example 10-3 JCL to Unload and Load data to and from DB2 for z/OS tables
//PAOLLOAD JOB (999,POK),'DB2LOAD-1',CLASS=A,MSGCLASS=T,
// NOTIFY=&SYSUID,TIME=1440,REGION=0M,MSGLEVEL=(1,1)
//*
//JOBLIB DD DSN=DB2G7.SDSNLOAD,DISP=SHR
In moving data between two DB2 for z/OS tables, you can use three output formats
compatible with the Load utility. These are: DSNTIAUL, VARIABLE format, and the USER
format. Of these three, it is best to use the DSNTIAUL if you are not doing data type
transformation (example decimal to integer, or char to varchar) while unloading data. It is a lot
easier and less prone to error to use the DSNTIAUL. However, if you need to do some data
type transformations, it is best to use the USER format.
You should also specify QUIESCE YES and QUIESCECAT YES so that any late changes in
the source table will be included in the output. When this is specified, you can only proceed
with it when the table is finished in the QUIESCE operation, and the data in the buffer is
already flushed in the disk.
The SORTOUT and SYSUT1 data sets are not required because the target table in this
example is not indexed. See Example 10-4.
The database object used in this example are in Table 10-4 on page 251. The options used in
this example are explained in Table 10-7.
Unload options
DB2 YES HPU can pass the query to DB2 for execution if
the SQL Select cannot be performed by the HPU
program.
Other options: DB2 NO, DB2 FORCE
Load options
Look at Example 10-4 to see an example of a HPU job for moving data between two
mainframe DB2 tables
Example 2: HPU and Load with the last full image copy as source
The HPU can unload the last incremental copy of a database back-up and place it in a data
set. This data set will then be used as input of the Load utility. In this example, we have two
JCL steps in our job. The first step unloads the the full image copy and the second step loads
to the target table. The latest full image copy is automatically updated in the
SYSIBM.SYSCOPY table every time a back-up is made on a table space. HPU refers to the
SYSCOPY table to determine where the latest full image copy is stored. The output data set
of the HPU job step is the PAOLOR2.MD.HPUNLOAD.DATA2, which has a DSNTIAUL format.
In the second JCL step, we use the LOAD utility to load data into the PAOLOR3.DEPT table.
The SYSUT1 and the SORTOUT data sets are needed because the PAOLOR3.DEPT is an
indexed table. The index will be re-written after the new data is inserted into the table. Hence,
the SORTOUT and SYSUT1 data sets will be used as work data sets for the sort and
indexing. See Example 10-5.
Unload options
COPYDDN LAST_IC This option indicates that the last image copy of
PAOLOR2.DEPT will be used as the source of
data. This is different from the existing
PAOLOR2.DEPT table. The last image copy is
the latest back-up of the table. The name of the
data set that has last image copy will be read
from the SYSIBM.SYSCOPY table.
Load options
Look at Example 10-5 to see a HPU job for moving data between two mainframe DB2 tables.
Example 10-5 HPU and Load using a full image copy of the back-up
//PAOLJOB3 JOB (999,POK),'HPUNLOAD',CLASS=A,MSGCLASS=T,
// NOTIFY=&SYSUID,TIME=1440,REGION=0M,MSGLEVEL=(1,1)
//*
//***************************************************************
//* STEP 1: HPU TOOL - UNLOAD IN FORMAT DSNTIAUL *
//* (UNLOAD FROM LAST INCREMENTAL COPY) *
//***************************************************************
//*
//STEP1 EXEC PGM=INZUTILB,REGION=0M,DYNAMNBR=99,
// PARM='DB2G,HPUNLOAD'
//STEPLIB DD DSN=INZ.V2R1M0.SINZLINK,DISP=SHR
// DD DSN=DB2V710G.SDSNEXIT,DISP=SHR
// DD DSN=DB2G7.SDSNLOAD,DISP=SHR
//SYSIN DD *
UNLOAD TABLESPACE DSNDB04.DEPT
COPYDDN LAST_IC
//SYSPRINT DD SYSOUT=*
//COPYDD DD SYSOUT=*
//OUTDD DD SYSOUT=*
//UTPRINT DD SYSOUT=*
//LOADDD DD SYSOUT=*
//UNLDDN1 DD DSN=PAOLOR2.MD.HPUNLOAD.DATA2,
// DISP=(NEW,CATLG,CATLG),UNIT=SYSDA,
// SPACE=(TRK,(10,20),RLSE)
//*
//***************************************************************
//* STEP 2: LOAD UTILITY - LOADS DATA UNLOADED IN STEP 1 *
//* (FORMAT: DSNTIAUL) *
//***************************************************************
//*
//STEP2 EXEC DSNUPROC,UID='LOADUTIL',UTPROC='',SYSTEM='DB2G'
//STEPLIB DD DSN=DB2G7.SDSNLOAD,DISP=SHR
//SYSREC DD DSN=PAOLOR2.MD.HPUNLOAD.DATA2,DISP=SHR
//SYSUT1 DD DSN=PAOLOR2.LOAD.SYSUT1,
Example 3: HPU from two DB2 z/OS source tables to one target
In this example we unload data from two DB2 for z/OS tables and put it in one target DB2 for
z/OS table. Notice that PAOLOR2.DEPT(table 1) and PAOLOR7.DEPT(table 2) are located in
different table spaces. One JCL job will be used for the unload and load operation. See
Example 10-6.
Database objects
The database object used in this example are in Table 10-4 on page 251. Another source
table is used in this example. PAOLOR3.DEPT has similar properties as PAOLOR7.DEPT, but
they are located in different table spaces.
The options used in this example are explained below. See Table 10-9.
Unload options
Load options
See Example 10-6, for a sample JCL to use HPU to unload two DB2 tables and load it to one
table using the Load utility.
Example 10-6 JCL to HPU two DB2 for z/OS tables to one target table
//PAOLJOB4 JOB (999,POK),'HPUNLOAD',CLASS=A,MSGCLASS=T,
// NOTIFY=&SYSUID,TIME=1440,REGION=0M,MSGLEVEL=(1,1)
//*
//***************************************************************
//* STEP 1: HP UNLOAD TOOL - UNLOAD IN FORMAT DSNTIAUL *
//***************************************************************
//*
//STEP1 EXEC PGM=INZUTILB,REGION=0M,DYNAMNBR=99,
// PARM='DB2G,HPUNLOAD'
//STEPLIB DD DSN=INZ.V2R1M0.SINZLINK,DISP=SHR
// DD DSN=DB2V710G.SDSNEXIT,DISP=SHR
// DD DSN=DB2G7.SDSNLOAD,DISP=SHR
//SYSIN DD *
UNLOAD TABLESPACE
DB2 NO
QUIESCE YES QUIESCECAT NO
OPTIONS DATE DATE_A
We will use the same HPU and Load options as the one we used in Example 3. The only
condition that we changed is that the target table resides in a different DB2 subsystem in a
different LPAR.
We need to separate the two JCL steps and run the jobs in different LPARs. The job for the
HPU should be submitted at the DEV1 LPAR, while the job for the Load utility should be
submitted at the PROD1 LPAR.
The output data sets of the HPU job which are PAOLOR2.MD.HPUNLOAD.DATAJO41 and
PAOLOR2.MD.HPUNLOAD.DATAJO42 should be made accessible to the PROD1 LPAR. It
could be through FTP or through removable media. Then you can use these data sets as the
input of the Load utility JCL (SYSREC).
To change the subsystem, you just need to change the SYSTEM parameter on the EXEC
statement of the JCL, and set it to the DB2 subsystem name that you want to access. See
Example 10-8.
After the Federated Database is set-up, you can use the SQL Insert to write data to the target
z/OS database table. The SQL sub-select is used to retrieve the data from the source DB2 on
distributed database table.
First, connect to the database in the client machine where the Federated Database is defined:
CONNECT TO SAMPAIX8
Then, issue the Insert with subselect command to transfer the data to the target:
INSERT INTO DB2ADMIN.DEPT390T
SELECT * FROM DB2ADMIN.DEPT390S
You can also specify the columns that you want to retrieve in your Select statement. The
subselect is like a regular SQL Select statement. You can have a Where clause and scalar
functions in your Select statement as long as the result set matches the columns of your
target table:
INSERT INTO DB2ADMIN.DEPT390T(DEPTNO, DEPTNAME, ADMRDEPT)
SELECT DEPTNO,DEPTNAME,ADMRDEPT
FROM DB2ADMIN.DEPT390S
WHERE DEPTNO IN (‘A00’,’B00’,’C00’)
You can use SQL Insert with sub-select to move data across different DB2 subsystems.
These DB2 subsystems have to be defined in the Federated Database. Once nicknames
have been created for the remote relational table, you can use these nicknames like regular
table names in the SQL Insert and sub-select statement.
Note: You can use DB2 Data Joiner to access data from different relational databases and
use the SQL Insert with sub-select to move data between different relational databases,
like Oracle or MS SQL Server. With this technique you are only limited by the databases
that you can connect to your Federated Database system.
The examples in this chapter show how to move actual data. It is assumed that all database
objects exist on the target database. See Chapter 9., “Getting ready for moving data” on
page 213.
We recommend the Cross Loader for z/OS to read data from distributed databases or from
nicknames in a Federated Database system. This is based on three-part names with the
location defined in the CDB. The Load utility will reserve the data to be loaded through a
cursor.
With the Import utility on distributed, you can do SQL Insert for IXF formatted data from a file
or named pipe. For the time being IXF data has to be produced by the Export utility. At
present, HPU for MP cannot produce IXF.
You can create a nickname on mainframe table in a Federated Database system. By using
SQL Insert into a nickname, you can sub-select from a table or another nickname in the
Federated Database system.
HPU for z/OS is a very efficient tool in unloading data from DB2 for z/OS databases. Its
strength is its ability to read the VSAM files directly. It also consumes less CPU processing
than the Unload utility. However, they are nearly equal in speed performance. HPU can
customize the output using the SQL Select and the USER format. Another advantage of HPU,
is it can read incremental copies. The HPU is recommended for unloading data when the
Select statement can be performed by the HPU and not by the DB2 engine. The HPU is
separately priced tool, while the Unload utility is included in the DB2 for z/OS Utility suite
package.
You should consider changing the existing solutions that use the DSNTIAUL program. The
HPU can produce output formats compatible with the DSNTIAUL. But it saves on the
overhead time required to pass the query to DB2 if the query is relatively simple. The
DSNTIAUL always call DB2 to perform its query.
There is no alternative to the Load utility in the mainframe. This will load data from the data
set produced by HPU or from the Unload utility. The Cross Loader in z/OS also uses the Load
utility taking input from a cursor declared on a mainframe table.
With regards to the Data Propagator, the same considerations as from distributed is valid.
10.4.3 Miscellaneous
Code page conversion in our examples are done automatically using the HPU, the Unload
utility or the Load utility.
Moving data to a DB2 for z/OS database is supported by several tools and utilities. These
tools and utilities are constantly being improved through PTFs and FixPaks. You can get the
latest list of PTF and FixPaks on the Web sites:
http://www.ibm.com/support/us/
http://www-3.ibm.com/software/data/db2/
Mainframe Distributed
DB2
Connect Cross Cross Loader
Loader with cursor
(only if Source
Load Table's DB =
Target Table's
DB2 utility DB)
DB2 A,D
DPropR Target
(I)
CD
Apply table
table
Source DPropR
table Capture
Import A,D,I File/
utility pipe
I
D, I
The letters written on the arrows represents the formats that you can choose between:
A Positional (fixed) format (ASC)
D Delimited format (DEL)
I Integrated exchange format, PC version (IXF)
(I) The IXF format is accepted, but the table has to exist
UA User defined Positional (fixed) format (ASC)
It is important to notice that the Export utility, the Cross Loader, and Insert with subselect can
all read from a nickname, but only Insert with subselect can write to a nickname (from Version
8.)
Export
W File/
pipe utility
DB2 W
r I,D r
Source
table a Source
Nickname
a
p Cross
Target Source
p
Loader
p Load
table table
p
utility
e Target
Nickname
e Target
table
r Insert with
subselect V.8
r
Import
utility
Note: If you are moving data from a Windows distributed environment to a UNIX
distributed environment, keep in mind that the Export utility on Windows
represents a newline as two characters (0x0D 0x0A). The Load utility and the
Import utility in a UNIX environment both do not recognize this two character
newline. They expect the newline character to be a single character (0x0A).
Therefore, it will not load Windows exported data properly (for DEL format only,
IXF is okay). Before performing the load or import, either FTP the DEL file from
the source to target machine in ASCII mode (which will convert two character
newlines to single character newlines), or perform the conversion yourself.
Note: There are two types of positional ASCII: FIXED length and FLEXIBLE length.
FIXED length means that the RECLEN option is specified during the import or load,
and that all records are of a fixed length. FLEXIBLE length means that the RECLEN is
not specified during the import or load, and records are delimited by the newline
character.
IXF (PC/IXF)
– Advantages
• Loading/Importing time is faster than DEL and ASC.
– Disadvantages
• Not supported in a partitioned database environment for Load, although it is
supported for Import.
• Data is in binary, and is not human readable.
In the case where the Import utility is being used, SQL inserts are used to populate the
target table. For tables containing indexes, this involves constant updates to the indexes. This
may be less efficient than dropping the indexes before the import and recreating them
afterwards, especially if the target table was originally empty or close to empty.
In the case where the Load utility is being used, the Load utility currently does not have the
ability to build multiple indexes in parallel, whereas the SQL CREATE INDEX command does.
Therefore, for a target table containing multiple indexes, it may be more efficient either to drop
the indexes before the load and recreate them afterwards, or perform the load with INDEXING
MODE DEFERRED, especially if the target table was originally empty or close to empty.
When a load to a table is executed with INDEXING MODE DEFERRED, the table’s indexes
are marked bad and the load’s BUILD phase is skipped. Subsequent access of the table’s
indexes (apart from another load) will automatically force the indexes to be rebuilt.
PAOLOR2.EMP
COLUMN NAME DATA TYPE LENGTH NULLS
EMPNO CHAR 6 NO
FIRSTNME VARCHAR 12 NO
MIDINIT CHAR 1 NO
LASTNAME VARCHAR 15 NO
WORKDEPT CHAR 3 YES
PHONENO CHAR 4 YES
HIREDATE DATE YES
JOB CHAR 8 YES
EDLEVEL SMALLINT YES
SEX CHAR 1 YES
BIRTHDATE DATE YES
SALARY DECIMAL ( 9, 2) YES
SC246300.LITERATURE
COLUMN NAME DATA TYPE LENGTH NULLS
TITLE CHAR 25 YES
IDCOL ROWID NO
MOVLENGTH INTEGER YES
LOBMOVIE BLOB 2048 YES
LOBBOOK CLOB 10240 YES
MARKOMP.EMP
Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
EMPNO SYSIBM CHARACTER 6 0 No
FIRSTNME SYSIBM VARCHAR 12 0 No
MIDINIT SYSIBM CHARACTER 1 0 No
LASTNAME SYSIBM VARCHAR 15 0 No
WORKDEPT SYSIBM CHARACTER 3 0 Yes
PHONENO SYSIBM CHARACTER 4 0 Yes
HIREDATE SYSIBM DATE 4 0 Yes
JOB SYSIBM CHARACTER 8 0 Yes
EDLEVEL SYSIBM SMALLINT 2 0 Yes
SEX SYSIBM CHARACTER 1 0 Yes
BIRTHDATE SYSIBM DATE 4 0 Yes
SALARY SYSIBM DECIMAL 9 2 Yes
BONUS SYSIBM DECIMAL 9 2 Yes
COMM SYSIBM DECIMAL 9 2 Yes
MARKOMP.LIT
Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
TITLE SYSIBM CHARACTER 25 0 Yes
IDCOL SYSIBM VARCHAR 40 0 No
MOVLENGTH SYSIBM INTEGER 4 0 Yes
LOBMOVIE SYSIBM BLOB 2048 0 Yes
LOBBOOK SYSIBM CLOB 10240 0 Yes
MIKEMP.EMP
Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
EMPNO SYSIBM CHARACTER 6 0 No
FIRSTNME SYSIBM VARCHAR 12 0 No
MIDINIT SYSIBM CHARACTER 1 0 No
LASTNAME SYSIBM VARCHAR 15 0 No
WORKDEPT SYSIBM CHARACTER 3 0 Yes
PHONENO SYSIBM CHARACTER 4 0 Yes
HIREDATE SYSIBM DATE 4 0 Yes
JOB SYSIBM CHARACTER 8 0 Yes
EDLEVEL SYSIBM SMALLINT 2 0 Yes
SEX SYSIBM CHARACTER 1 0 Yes
BIRTHDATE SYSIBM DATE 4 0 Yes
SALARY SYSIBM DECIMAL 9 2 Yes
BONUS SYSIBM DECIMAL 9 2 Yes
COMM SYSIBM DECIMAL 9 2 Yes
Observe that:
db2g is cataloged as hostdb on distdb and can be accessed from this.
distdb is cataloged as distdb on distdb2 and can be accessed from this.
Outline
1. If the source does not exist in the same database as the target, use Federated Database
support to create a nickname for the source (see Appendix A, “Defining a Federated
Evaluation
Restrictions:
– DB2 UDB V8 has to be used on the distributed environment.
– A Federated database must be used if the source is not in the same database as the
target.
– For the Load, see Chapter 6, “Load with DB2 Distributed” on page 91.
Performance:
– Using the fastest tool available on the target side
– Data retrieved from the source through an SQL query statement
Usability:
– The process is administered only on a distributed environment.
– Since the source can be a nickname, the source can be anything that Federated
databases support, even other database products. The only downside is that some
additional setup is needed to create table nicknames when needed.
– It is easy to use, and no intermediate data files are produced.
Example
The following example demonstrates how the Cross Loader can be used to move data from a
mainframe system to distributed. However, it can be used to move data from any source that
Federated Databases support, to distributed.
In this example:
In the Federated Database distdb, MARKOMP.EMPHOST was set up as a nickname for
the table PAOLOR2.EMP that belonged to the mainframe database db2g (see 11.1.3,
“Environment used for data movement examples” on page 271 for more details.)
This example is applicable to both a partitioned database environment and a
non-partitioned database environment.
Outline
1. Export the data from the source table into a file or a named pipe. Exporting to a named
pipe provides the following benefits:
– You can save space in the file system, since no intermediate data file is generated.
– The exporting and loading/importing processes will be performed simultaneously.
2. If the source is not in the same database as the target, you have several choices for the
database connection:
– If the source database is on a distributed system, you can CATALOG it locally and then
connect to it.
– If the source database is on a system that is supported by DB2 Connect (for example,
a mainframe system), you can CATALOG it locally and then connect to it (DB2 Connect
will be used automatically). Appendix B, “DB2 connectivity” on page 307 contains
examples on how to CATALOG a mainframe database.
– If the source database in on a system that is supported by Federated databases, you
can create a nickname for the source inside your target table’s database. Then you can
connect to your target table’s database and export from the nickname. For details on
setting up a Federated Database, see Appendix A, “Defining a Federated Database”
on page 299.
3. There are restrictions on the file types allowed and whether or not using a named pipe is
allowed. Restrictions are listed in the next section.
4. If possible, use the Load utility to move the data from the file or pipe into the target table,
unless the amount of data to move is small (in which case, the import utility may perform
faster). In some situations, it will be necessary to use the Import utility.
Evaluation
Restrictions:
– Only the IXF format is supported if the export is being performed through DB2
Connect. Additionally, if the target distributed system is in a partitioned database
environment, you have the following choices:
• If the environment is Version 8 or higher, load the IXF file using the
LOAD_ONLY_VERIFY_PART mode (see “Loading IXF files in a Version 8
partitioned database environment” on page 97 for more details.)
• Use the Import utility.
– The Export and Load/Import must use the LOBSINFILE modifier if LOB objects greater
than 32K in length are involved.
– You cannot export into a named pipe in the following situations:
• The LOBSINFILE modifier is being used.
• A load is being performed in LOAD_ONLY_VERIFY_PART mode in a partitioned
database environment.
– For the Load or AutoLoader utility, see Chapter 6, “Load with DB2 Distributed” on
page 91.
Examples
The following examples demonstrate how the data can be moved from a mainframe system to
distributed. However, as mentioned earlier, data can be moved from other source types,
including any source that Federated Databases support.
In this example:
Since a connection was made to a mainframe system, it was made through DB2 Connect.
Therefore, the IXF file format was required.
The Import utility could have been used instead of the Load utility. For small amounts of
data, an import may be faster than a load due to the Load utility’s startup and shutdown
overhead.
Next, to perform an export and a simultaneous load, you can run two separate CLP sessions
simultaneously as follows:
CLP Session 1:
CONNECT TO hostdb USER paolor2 USING xxyyzz
EXPORT TO mypipe OF ixf MESSAGES export.msg select * from PAOLOR2.EMP
CONNECT RESET
CLP Session 2 (to import, replace “LOAD” with “IMPORT”):
Note: Using a named pipe is only possible if the LOBSINFILE modifier is not used.
Outline
1. If the source does not exist in the same database as the target, use Federated Database
support to create a nickname for the source (see Appendix A, “Defining a Federated
Database” on page 299 for more details.)
2. It is recommended that the target table be created with the NOT LOGGED INITIALLY
property specified, and that the ALTER TABLE command be executed against the table
specifying APPEND ON. If there are any indexes defined on the table, it is recommended
that they be dropped before the insert and recreated afterwards. Doing these things will
help to optimize the performance of the insert.
Evaluation
Restrictions:
– DB2 UDB V8 has to be used on the distributed environment.
– A Federated database must be used if the source is not in the same database as the
target.
Performance:
– performance is likely suboptimal
Usability:
– The process is administered only on a distributed environment.
– Since the source can be a nickname, the source can be anything that Federated
databases support, even other database products. The only downside is that some
additional setup is needed to create table nicknames when needed.
– It is easy to use, and no intermediate data files are produced.
– It has some benefits over using the Cross Loader, such as it can fire triggers where as
the Load utility cannot.
Example
The following example demonstrates how an SQL insert can move data from a mainframe
system to distributed. However, it can be used to move data from any source that Federated
Databases support, to distributed.
Replication from non-database sources is also provided through the federated data support.
Outline
Pre-propagation activities:
1. Define your tables as sources for the replication.
2. Create new tables as targets for the replication.
3. Populate control tables for Capture and Apply process.
4. Define subscription set and members.
5. Schedule Apply process.
Because this is the most efficient, we have chosen to show the APPLY program using the
PULL technique. APPLY could also run on the mainframe side and use the PUSH technique
to insert the changes in the target table.
Mainframe Distributed
DB2
Connect
DB2 DB2
DB2
logs
EMP PRUN Mem- Col- State-
table CNTL ber umn ments
Evaluation
Compared to other function and tools, DPropR is not appropriate for one time data
movement. It is a tool that helps you keeping your databases in sync continuously or makes
captured changes available. To facilitate this, a preparation and customizing effort is
necessary.
You should consider DPropR if your need for data movement is based on continuously
updated information like this:
A complete or partial copy of a source table
A complete or partial copy of changes to a source table
An aggregate of a source table based on SQL column functions / GROUP BY
An aggregate of changes to a source table based on SQL column functions / GROUP BY
An updateable copy (replica) of all or portion of a source table
DPropR can also offer data transformation, filtering, complemental information, and derived
information during the propagation process.
For other DBMS, the capture of changes is based on triggers fired inside time critical UOWs,
but DPropR reads the undo and redo records in the database log. This does not influence the
application.
Important enhancements:
All stored passwords are encrypted.
Changes are not inserted in CD-tables until they have been committed.
No changes captured for your source unless the change affects your selected columns.
Changes from the master site should not be recaptured at the replica site.
Multiple Capture programs can run on the same DB2 database or subsystem.
Capture prunes changes concurrently with the capture of changes on DB2.
Faster full refreshes of target tables can be done using the load utility improvements.
A migration utility is included to convert existing DB2 Replication V5, V6, and V7
environments to DB2 Replication V8.
For a detailed discussion of enhancements, see IBM DB2 Universal Database Replication
Guide and Reference Version 8, SC27-1121-00.
Outline
1. HPU for z/OS can unload data into a delimited or a positional file. For the delimited file,
make sure to specify that null indicators should not be enclosed by delimiters. For the
positional file, make sure to specify external formats and padding.
This are the only formats available on z/OS that can be read by utilities running on a
distributed environment.
You can unload either ASCII or EBCDIC.
2. Transfer the file from the host to the multiplatform workstation. If the unloaded files on the
z/OS are in EBCDIC, specify ASCII as FTP option, else use BIN as option.
3. Use the Load utility to insert the data into the target table. If the target database is
partitioned and you are using DB2 UDB V7 or older, use the AutoLoader to insert the data
into the target table. Note that the Import utility can be used in this step. For small amounts
of data, an import may be faster than a load due to the Load utility’s startup and shutdown
overhead.
Evaluation
Restrictions:
– For HPU, keep in mind that tables containing LOB objects are not supported. Also, see
Chapter 7, “IBM DB2 High Performance Unload for z/OS” on page 119.
– For the Load or AutoLoader utility, see Chapter 6, “Load with DB2 Distributed” on
page 91.
– For the Import utility, see Chapter 5, “Export and Import with DB2 distributed” on
page 79.
Examples
The following are examples on using the HPU for z/OS and then subsequently using the Load
or Import utility to load the data into the distributed database distdb.
Example 11-4 shows the file unload_ebcdic_del.txt after being FTP to the distributed system.
Notice that NULL values are represented with ;; and ; if it is at the last column.
Note: The character delimiter 0x2A (asterisk) and column delimiter 0x3B (semicolon)
are specified in the load command.
For Version 7, if you are using the db2atld utility in a partitioned database environment, the
above Load command can be used in the autoloader configuration file.
Importing into MARKOMP.EMP can be accomplished by using the following CLP commands:
CONNECT TO distdb USER markomp USING aabbcc
import from unload_ebcdic_del.txt of del modified by chardel0x2A coldel0x3B replace into
MARKOMP.EMP
Columns that need to be treated different than the default, must all be specified in the user
block:
TYPE In this example, the VARCHAR columns are converted to CHAR and
given the maximum length. The SMALINT and DECIMAL columns are
converted to CHAR and given a length that includes sign and decimal
separator.
PADDING If the contents of the column is less than the maximum, ‘ ‘ (blanks) are
padded to the left (see next).
JUST LEFT Specifies that the output string is justified to the left
/*
//SYSPRINT DD SYSOUT=*
//COPYDD DD SYSOUT=*
//OUTDD DD SYSOUT=*
//UTPRINT DD SYSOUT=*
//LOADDDN1 DD SYSOUT=*
//*
//********* DDNAMES USED BY THE SELECT STATEMENTS **********
//*
//UNLDDN1 DD DSN=PAOLOR2.MD.HPUNLOAD.EBCDIFIX,
// DISP=(NEW,CATLG,CATLG),
// UNIT=SYSDA,
// SPACE=(TRK,(10,20),RLSE)
Example 11-6 shows the load statements generated. This will be useful when defining the
column list pairs to the Load utility on the distributed.
Example 11-8 shows the file unload_ebcdic_fixed.hpu.txt to be loaded on the distributed side
after being converted to ASCII during the FTP. The NULL indicators appears as a ’ÿ‘.
Note: The flexible length positional ASC format is used here. This is indicated by the
lack of the RECLEN modifier being used in the load command. Also notice that the
STRIPTBLANKS modifier is being used here. Without specifying it, VARCHAR column
data would have been padded with trailing blanks.
For Version 7, if you are using the db2atld utility in a partitioned database environment, the
above load command can be used in the autoloader configuration file.
Importing into MARKOMP.EMP can be accomplished by using the following CLP commands:
CONNECT TO distdb USER markomp USING aabbcc
import from unload_ebcdic_fixed.hpu.txt of ASC modified by nullindchar=0xFF STRIPTBLANKS
method l (1 6, 7 18, 19 19, 20 34, 36 38, 40 43, 45 54, 56 63, 65 70, 72 72, 74 83, 85
97, 99 111, 113 125) null indicators (0, 0, 0, 0, 35, 39, 44, 55, 64, 71, 73, 84, 98,
112) replace into MARKOMP.EMP
Outline
1. Unload utility on z/OS can unload data into a positional file. Make sure to specify external
formats and keep the default padding.
You can unload either ASCII or EBCDIC.
2. Transfer the file from the host to the distributed system. If the unloaded files on the z/OS
are in EBCDIC, specify ASCII as FTP option, else use BIN as option.
3. Use the Load utility to insert the data into the target table. If the target database is
partitioned and you are using DB2 UDB V7 or older, use the AutoLoader to insert the data
into the target table. Note that the import utility can be used in this step. For small amounts
of data, an import may be faster than a load due to the Load utility’s startup and shutdown
overhead.
Evaluation
Restrictions:
– For Unload utility, see Chapter 3, “Unload with DB2 for z/OS” on page 33.
– For the Load or AutoLoader utility, see Chapter 6, “Load with DB2 Distributed” on
page 91.
– For the Import utility, see Chapter 5, “Export and Import with DB2 distributed” on
page 79.
– Formats to be used
• Positional ASCII (ASC). Be aware of the restrictions outlined in 11.1.1, “File format
considerations” on page 269.
Performance:
– Using fastest tools available on both platforms (unless import is chosen)
Usability:
– Need to administer the process on both z/OS and multiplatform
– Need to manually manage and transfer files
Examples
The following are examples on using the Unload tool, and then subsequently using the Load
or Import utility to load the data into the distributed database distdb.
Example 11-10 shows the result from the Unload utility run. The load statements with
positions can be useful when defining the input file for the Load utility.
Attention: To correct position error in the generated load statements (only when including
varchar columns), make sure that PTF XXXX for APAR PQ66712 is applied to your system.
Example 11-11 FTP the file of Example 11-9 from a DOS window
Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.
Example 11-12 shows the output file unload_ebcdic_fixed.txt from the Unload after it is
transferred and converted to ASCII on the distributed.
Note: The fixed length positional ASC format is used here. This is indicated by the use
of the RECLEN modifier in the load command. Also notice that the STRIPTBLANKS
modifier is being used here. Without specifying it, VARCHAR column data would have
been padded with trailing blanks.
For Version 7, if you are using the db2atld utility in a partitioned database environment, the
above load command can be used in the autoloader configuration file.
Importing into MARKOMP.EMP can be accomplished by using the following CLP commands:
CONNECT TO distdb USER markomp USING aabbcc
import from unload_ebcdic_fixed.txt of ASC modified by nullindchar=0xFF reclen=131
STRIPTBLANKS method l (3 8, 11 22, 23 23, 26 40, 42 44, 46 49, 51 60, 62 69, 71 81, 83
83, 85 94, 96 106, 108 118, 120 130) null indicators (0, 0, 0, 0, 41, 45, 50, 61, 70,
82, 84, 95, 107, 119) replace into MARKMO.EMP
Unload LITERATURE table (with LOB data) in POSITIONAL format with the
unload utility
Example 11-13 shows the JCL for the Unload utility to run. LOB data columns must be less
than 32 KB in length, since this is the limit for inline data used with Import and Load. This limit
can be overcome by using the LOBSINFILE option.
Example 11-14 shows the load statements for the LITERATURE table.
Note: The flexible length positional ASC format is used here. This is indicated by the
lack of the RECLEN modifier being used in the load command. Also notice that the
STRIPTBLANKS modifier is being used here. Without specifying it, VARCHAR column
data would have been padded with trailing blanks.
For Version 7, if you are using the db2atld utility in a partitioned database environment, the
above load command can be used in the autoloader configuration file.
Importing into MARKOMP.LIT can be accomplished by using the following CLP commands:
Outline
1. Use the HPU to unload the data from the source table into a file or a named pipe.
Unloading to a named pipe provides the following benefits:
– You can save space in the file system, since no intermediate data file is generated.
– The exporting and loading/importing processes will be performed simultaneously.
2. The source table has to reside on the same machine where HPU runs.
3. There are restrictions on the file types allowed and whether or not using a named pipe is
allowed. Restrictions are listed in the next section.
4. If possible, use the Load utility to move the data from the file or pipe into the target table,
unless the amount of data to move is small (in which case, the import utility may perform
faster). In some situations, it will be necessary to use the Import utility.
Evaluation
Restrictions:
– For the HPU for MP, see Chapter 8, “IBM DB2 High Performance Unload for
Multiplatforms” on page 193.
– For the Load or AutoLoader utility, see Chapter 6, “Load with DB2 Distributed” on
page 91.
– For the Import utility, see Chapter 5, “Export and Import with DB2 distributed” on
page 79.
– Do not specify a named pipe to unload into if you are generating LOB files.
– Currently supported formats are (see 11.1.1, “File format considerations” on page 269
before choosing which file format to use):
• DEL
• IXF
Note: For the SELECT statement used, it is recommended that you use one that
is a basic “SELECT * from table” or “SELECT col1,col2,etc from table”. If you
specify a statement that is too complex, HPU will invoke the Export utility, which
in most cases is not as fast.
Performance:
– Using the fastest tool available on both, source and target side
– Data retrieved from the source through a select statement only if
Usability:
– The process is administered only on the distributed environment
– Need to manually manage files or named pipes
Part 5 Appendixes
For more details on federated systems and Federated Databases, and of course specifics on
the new V8 functions, refer to the DB2 UDB Federated Systems Guide Version 8, SC09-4830.
What follows are examples on how to set up Federated Databases in both v7 and v8 using
CLP commands, against both a distributed environment and a mainframe environment, see
Figure A-1.
Important: It is recommended that the DBNAME value (in this case, rmtdb) be
specified in uppercase.
Important: The meaning of the DBNAME value in the CREATE SERVER command
differs between version 7 and Version 8. When creating a SERVER for a version 7
Federated Database, the DBNAME refers to the name of the database on the
remote system. That database does not have to be CATALOGed locally before
creating the SERVER.
5. If the Federated Database fedv8 has not been created yet, then create it. CLP command:
CREATE DATABASE fedv8
6. Connect to fedv8. CLP command:
CONNECT TO fedv8
7. Create a WRAPPER that corresponds with the remote system. In this case, the correct
wrapper to choose is DRDA. CLP command:
CREATE WRAPPER DRDA
8. Create a SERVER against the remote system. For this example, the server will be called
distsrvr. CLP command:
CREATE SERVER distsrvr TYPE DB2/UDB VERSION 7.0.0 WRAPPER DRDA AUTHORIZATION
"rmtuser" PASSWORD "rmtpwd" OPTIONS (NODE 'distnode', DBNAME 'RMTDBLCL')
Important: It is recommended that the DBNAME value (in this case, rmtdblcl) be
specified in uppercase.
Important: The meaning of the DBNAME value in the CREATE SERVER command
differs between version 7 and Version 8. When creating a SERVER for a Version 8
Federated Database, the DBNAME refers to a locally CATALOGed database. This
means that remote databases must first be CATALOGed locally before creating the
SERVER.
SQLNET wrapper
Table A-5 Oracle data sources supported by Oracle SQL*Net V1 or V2 client software
Server type Data source
NET8 wrapper
Table A-6 Oracle data sources supported by Oracle Net8 client software
Server type Data source
Other wrappers
Please consult wrapper documentation.
A company's distributed environment relies on the distributed data facility (DDF), which is part
of DB2 for OS/390 and z/OS. DB2 applications can use DDF to access data at other DB2
sites and at remote relational database systems that support Distributed Relational Database
Architecture (DRDA). DRDA is a standard for distributed connectivity. All IBM DB2 servers
support this DRDA standard.
DDF also enables applications that run in a remote environment that supports DRDA. These
applications can use DB2 Connect and DDF to access data in DB2 servers on z/OS. DB2
Connect provides connectivity to mainframe or AS/400 from Windows, OS/2, and
UNIX-based platforms. You can connect to DB2 databases on AS/400, VSE, VM, MVS,
OS/390 and z/OS. You can also connect to non-IBM databases that comply with the
Distributed Relational Database Architecture (DRDA). DB2 Connect has several connection
solutions:
Personal Edition, which provides direct connectivity to host or AS/400 databases
Enterprise Edition, which provides indirect connectivity that allows clients to access host
or AS/400 databases through the DB2 Connect server
This appendix describes the minimum customizing the redbook team had to do:
Communication database on DB2 for z/OS
Cataloging the databases on DB2 distributed
Figure B-1 shows how the mainframe and the distributed environment is connected.
DB2
z/OS Connect DB2
DDF
DB2
CDB WINDOWS
When z/OS is the requestor, DDF will use the location part of the 3.part name to find correct
IP-address and portno to the server in its own CDB for the outgoing requests. This includes
user name and password as well:
SELECT * FROM SAMPAIX.DB2INST1.EMP
When distributed is the requestor, the DB2 subsystem on z/OS must be cataloged as a
database in the distributed system.The DDF verifies the incoming requests against the
SYSIBM.LUNAMES table in the CDB. If it is not a row with blank in the LUNAME column,
DB2 rejects client connections that do not explicitly state a valid LUNAME.
When sending a request from z/OS, DB2 uses the LINKNAME column of the
SYSIBM.LOCATIONS table to determine which protocol to use. If the value in the LINKNAME
column is found in the:
SYSIBM.IPNAMES table, TCP/IP is used for DRDA connections
SYSIBM.LUNAMES table, SNA is used
The table SYSIBM.LUNAMES defines the security and mode requirements for conversations
with other systems. Decisions about how to populate this table depend on how you intend to
use DB2:
If you use this system only as a server, DB2 can use a blank in the LUNAME column as a
default.
If this DB2 requests data from other systems, you need to provide LU names or IP names
for those systems.
If you do not have a row with a blank in the LUNAME column, DB2 rejects client connections
that do not explicitly state a valid LUNAME.
For details, see DB2 Universal Database for OS/390 and z/OS Installation Guide,
GC26-9936-02, and DB2 Universal Database for OS/390 and z/OS Administration Guide,
SC26-9931-02.
Note: SYSIBM.LUNAMES must at least contain the default row inserted in the
DSNTIJSG installation job.
Restriction: Column LOCATION is the primary key in the LOCATIONS table, which means
you have to create alias on databases with the same name.
SYSIBM.IPNAMES
SYSIBM.USERNAMES
You should ensure that the LUNAMES table contains at least the row shown in Example B-5
and that the LUNAME is blank:
Important: You have to stop and start the DB2 DDF address space to make the changes
in the CDB tables effective. If not, this error occurs when you try a select:
SQLCODE = -30061, ERROR: RDB NOT FOUND
If you get a SQL -805 on package DSNESM68 shown in Example B-6, you have to bind it
shown in Example B-7.
Be aware of the warnings you get in the bind result, see Example B-8:
Note: If you are using repeatable read, you also have to bind the DSNESPRR plan
qualified with the same location name.
Example B-9 shows the result from a SQL statement where the location name is not defined
in the CDB:
SELECT * FROM AIXSAMP.DB2INST1.STAFF
Example: B-9 The location name of the remote site is not defined in the CDB
DSNT408I SQLCODE = -950, ERROR: THE LOCATION NAME SPECIFIED IN THE CONNECT
STATEMENT IS INVALID OR NOT LISTED IN THE COMMUNICATIONS DATABASE
Example B-10 shows the result set from a successful execution in SPUFI:
Note: To activate the connection to the database on windows, you have to bind the
DSNESPCS and DSNESPRR plans qualified with the actual location name. In this
scenario, it means SAMPWIN.
The easiest way to set up the mainframe connection is to use the Client Configure Assistant.
DB2 have to be installed and activate the wizard like this:
start menu ==> Program ==> IBM DB2 ==> Client Configuration Assistant
During this project we used DB2 subsystem DB2G on the mainframe in Poughkeepsie.
Figure B-2 shows the first window and the databases that are configured. Push the ADD
button.
If the IP-address is known, choose Manually In Figure B-3 and press the Next button.
Type the IP-address and the Port number to the mainframe as shown In Figure B-5 and press
the Next button.
Type the subsystem name on the mainframe as shown In Figure B-6 and press the Next
button. Use the comment field for more details.
The following 4 windows are optional and we did not fill them out:
5 — ODBC
6 — Node options
7 — Security options
8 — Host options
After the eight windows, test the connection as shown In Figure B-7. When you get The
connection test was successful click the OK button. Hopefully, the mainframe connection
is added to list of available databases in Figure B-2.
The equivalent test connection CLP script to the sequence of panels in Figure B-7 is listed in
Figure B-11.
Although there are also some post-operation tasks that should be done in single table data
movements like Unload and Load operation. We will discuss these tasks on the chapter that
refer specifically to that tool or utility.
Migration is only supported from DB2 UDB V6 and later releases, and also Data Joiner
V2.1.1. Migration from DB2 V1.2. Parallel Edition is not supported. Earlier versions of DB2
(Database Manager) must be migrated to V5.x or V6 before being migrated to a later release.
1. The migration command has to be issued from a client level corresponding to the release
level of the new database server. Migration from a down-level client is not supported.
2. Migration between platforms is not supported.
3. User objects within your database cannot have object names identical to reserved schema
names existing in the new release. These reserved schema names include: SYSCAT,
SYSSTAT and SYSFUN.
4. User-defined distinct types using the names BIGINT, REAL, DATALINK, or REFERENCE
must be renamed before migrating the database.
5. You cannot migrate a database that is in one of the following states:
– Backup pending
– Roll-forward pending
– One or more table spaces not in a normal state
– Transaction inconsistent
Pre-migration tasks
The pre-migration steps must be done on a previous release (that is, on your current release
before migrating to, or installing, the new release.)
1. Verify that there are no unresolved issues that pertain to “Migration restrictions” section.
2. Disconnect all applications and end users from each database being migrated (use the
LIST APPLICATIONS command, or the FORCE APPLICATIONS command, as
necessary.)
3. Use the DB2CKMIG pre-migration utility to determine if the database can be migrated (for
detailed information about using this utility, see the Quick Beginnings book for your
platform). Note that on Windows NT or OS/2, you are prompted to run this tool during
installation, but on UNIX based systems, this tool is invoked automatically during instance
migration.
4. Back up your database.
Migration is not a recoverable process. If you back up your database before the Version 6
reserved schema names are changed, you will not be able to restore the database using DB2
UDB Version 8. To restore the database, you will have to use your previous version of the
database manager.
You should also be aware that any database transactions done between the time the backup
was taken and the time that the upgrade to Version 8 is completed are not recoverable. That
is, if at some time following the completion of the installation and migration to Version 8, the
database needs to be restored (to a Version 8 level), the logs written before Version
8installation cannot be used in roll-forward recovery.
DATA
Identifies the data selected for unloading with table-name in the from-table-spec. The DATA
keyword is mutually exclusive with TABLESPACE, PART and LIST keywords and
from-copy-spec.
When you specify the DATA keyword, or you omit either the TABLESPACE or the LIST
keyword, you must also specify at least one FROM TABLE clause.
TABLESPACE
Specifies the table space (and, optionally, the database to | which it belongs) from which the
data is unloaded.
database-name
The name of the database to which the table space belongs. The name cannot be DSNDB01
or DSNDB07.
tablespace-name
The name of the table space from which the data is unloaded. The specified table space must
not be a LOB table space.
PART
Identifies a partition or a range of partitions from which the data is unloaded. This keyword
applies when the specified table space is partitioned; it cannot be specified with LIST. The
maximum is 254.
int1:int2
Designates a range of partitions from int1 to int2. int1 must be a positive integer that is less
than the highest partition number within the table space. int2 must be an integer greater than
int1 and less than or equal to the highest partition number.
If no PART keyword is specified in an UNLOAD control statement, the data from the entire
table space will be unloaded into a single unload data set.
FROMCOPY data-set-name
Indicates that data is unloaded from an image copy data set. When you specify FROMCOPY,
the Unload utility processes only the specified image copy data set. Alternatively, the
FROMCOPYDDN keyword can be used where multiple image copy data sets can be
concatenated under a single DD name.
data-set-name
Specifies the name of a single image copy data set.
The FROMCOPY image copy data set must have been created by one of the following
utilities:
COPY
# COPYTOCOPY
LOAD inline image copy
MERGECOPY
REORG TABLESPACE inline image copy
DSN1COPY
If the specified image copy data set is a full image copy, either compressed or uncompressed
records can be unloaded.
If the specified image copy data set is an incremental image copy or a copy of a partition or
partitions, you can unload compressed records only when the same data set contains the
dictionary pages for decompression. If an image copy data set contains a compressed row
and a dictionary is not available, then DB2 issues an error message.
When you specify FROMCOPY or FROMCOPYDDN, you can also specify selection criteria
with either PART, or FROM TABLE, or both, to qualify tables and rows to be unloaded.
FROMVOLUME
Identifies the image copy data set.
CATALOG
Identifies that the data set is cataloged. Use this option only for an image copy that was
created as a cataloged data set (its volume serial is not recorded in SYSIBM.SYSCOPY.)
FROMCOPYDDN ddname
Indicates that data is unloaded from one or more image copy data sets associated with the
specified DDNAME. Multiple image copy data sets (primarily for copy of pieces) can be
concatenated under a single DD name.
ddname
Identifies a DD name with which one or more image copy data sets are associated.
LIST listdef-name
Identifies the name of a list of objects that are defined by a LISTDEF utility control statement.
Index spaces, LOB table spaces, and directory objects must not be included in the list. You
cannot use the LIST option to specify image copy data sets.
When you specify the LIST option, the referenced LISTDEF identifies:
The table spaces from which the data is unloaded (you can use the pattern-matching
feature of LISTDEF.)
The partitions (if a table space is partitioned) from which the data is unloaded (defined by
the INCLUDE, EXCLUDE and PARTLEVEL keywords in the LISTDEF statement.)
The Unload utility associates a single table space with one output data set, except when
partition-parallelism is activated. When you use the LIST option with a LISTDEF that
represents multiple table spaces, you must also define a data set TEMPLATE that
corresponds to all the table spaces and specify the template-name in the UNLDDN option.
If you want to generate the LOAD statements, you must define another TEMPLATE for the
PUNCHDDN data set that is similar to UNLDDN. DB2 then generate a LOAD statement for
each table space.
PUNCHDDN
Specifies the DD name for a data set, or a template name, that defines one or more data set
names to receive the LOAD utility control statements that the Unload utility generates.
ddname
Specifies the DD name. The default is SYSPUNCH.
template-name
Identifies the name of a data set template that is defined by a TEMPLATE utility control
statement.
When you run the Unload utility for multiple table spaces and you want to generate
corresponding LOAD statements, you must have multiple output data sets that correspond to
the table spaces so that DB2 retains all of the generated LOAD statements. In this case, you
must specify an appropriate template name to PUNCHDDN. If you omit the PUNCHDDN
specification, the LOAD statements are not generated.
UNLDDN
Specifies the DD name for a data set or a template name that defines one or more data set
names into which the data is unloaded.
ddname
Specifies the DD name. The default is SYSREC.
template-name
Identifies the name of a data set template that is defined by a TEMPLATE utility control
statement.
If the specified name is defined both as a DDNAME (in the JCL) and as a template name (a
TEMPLATE statement), it is treated as the DDNAME.
When you run the Unload utility for a partitioned table space, the selected partitions are
unloaded in parallel if a template name is specified in UNLDDN and the template data set
name contains the partition as a variable (&PART. or &PA.). In this case, the template is
expanded into multiple data sets that correspond to the selected partitions. For example, the
data from partitions 2 and 5 of the table space testdb.testtsp1 are unloaded in parallel into two
data sets by using the following utility statement:
TEMPLATE unldtemp
DSNAME(&DBNAME..&TSNAME..P&PART.)
LISTDEF unldlist
INCLUDE TABLESPACE testdb.testtsp1 PARTLEVEL (2)
INCLUDE TABLESPACE testdb.testtsp1 PARTLEVEL (5)
UNLOAD LIST unldlist UNLDDN unldtempl ...
Similarly, when you run the Unload utility for multiple table spaces, the output records are
placed in data sets that correspond to the respective table spaces; therefore, the output data
sets must be physically distinctive, and you must specify an appropriate template name to
UNLDDN. If you omit the UNLDDN specification, the SYSREC DDNAME is not used and an
error occurs.
If the partition variable (&PART. or &PA). is included in TEMPLATE DSNAME when the
partition parallelism is not applicable (when the source is a non-partitioned table space or an
image copy), the variable is replaced by '00000' in the actual data set name. In this case,
warning message DSNU 1252 is issued, and the Unload utility issues return code 4.
EBCDIC
Specifies that all output data of the character type will be in EBCDIC. If a different encoding
scheme is used for the source data, the data is converted into EBCDIC (except for bit strings.)
If you do not specify either EBCDIC, ASCII, UNICODE, or CCSID, the encoding scheme of
the source data is preserved.
ASCII
Specifies that all output data of the character type will be in ASCII. If a different encoding
scheme is used for the source data, the data is converted into ASCII (except for bit strings.)
UNICODE
Specifies that all output data of the character type will be in UNICODE (except for bit strings.)
If a different encoding scheme is used for the source data, the data is converted into
UNICODE.
If you do not specify either EBCDIC, ASCII, UNICODE, or CCSID, the encoding scheme of
the source data is preserved. See the description of the CCSID option of this utility.
CCSID
Specifies up to three coded character set identifiers (CCSIDs) to be used for the data of
character type in the output records, including data unloaded in the external character
formats.It is coded as:
CCSID(integer1,integer2,integer3)
If the source data is of character type, the original encoding scheme is preserved. For
character strings that are converted from numeric data, date, time or timestamp, the default
encoding scheme of the table is used. For more information, see the CCSID option of the
CREATE TABLE statement in Chapter 5 of DB2 SQL Reference.
When a CCSID conversion is requested, CCSID character substitutions can occur in the
output string. Use the NOSUBS option to prevent possible character substitutions during
CCSID conversion.
NOSUBS
Specifies that CCSID code substitution is not to be performed during unload processing.
When a string is converted from one CCSID to another (including EBCDIC, ASCII, and
UNICODE), a substitution character is sometimes placed in the output string. For example,
this substitution occurs when a character (referred to as a codepoint) that exists in the source
If you specify the NOSUBS keyword and character substitution is attempted while unloading
data, it is treated as a conversion error. The record with the error is not unloaded, and the
process continues until the total error count reaches the number specified by MAXERR.
NOPAD
Specifies that the variable length columns in the unloaded records occupy the actual data
length without additional padding. As a result, the unloaded or discarded records might have
varying lengths.
When you do not specify NOPAD, default UNLOAD processing pads variable length columns
in the unloaded records to their maximum length, and the unloaded records have the same
length for each table.
The padded data fields are preceded by the length fields that indicate the size of the actual
data without the padding.
When the output records are reloaded using the LOAD utility, padded data fields are treated
as varying length data.
While LOAD processes records with variable length columns that are unloaded or discarded
by using the NOPAD option, these records cannot be processed by applications that only
process fields in fixed positions. For example, the LOAD statement generated for the EMP
sample table would look similar to the LOAD statement shown.
FLOAT
Specifies the output format of the numeric floating point data. This option applies to the binary
output format only.
S390
Indicates that the binary floating point data is written to the output records in the S/390®
internal format (also known as the hexadecimal floating point or HFP.)
IEEE
Indicates that the binary floating point data is written to the output records in the IEEE format
(also known as the binary floating point or BFP). The IEEE option is applicable only when
OS/390 Version 2 Release 6 or a subsequent version is installed, and a G5 or above
processor is present.
MAXERR
Specifies the maximum number of records in error that are allowed; the unloading process
terminates when this value is reached. It is coded as:
MAXERR integer
This value specifies the number of records in error that are allowed. When the error count
reaches this number, the Unload utility issues message DSNU1219 and terminates with
return code 8.
If multiple table spaces are being processed, the number of records in error is counted for
each table space. If the LIST option is used, you can add OPTION utility control statement
(EVENT option with ITEMERROR) before the UNLOAD statement to specify that the table
space in error is skipped and the subsequent table spaces are processed.
SHRLEVEL
Specifies whether other processes can access or update the table space or partitions while
the data is being unloaded.
Unload ignores the SHRLEVEL specification when the source object is an image copy data
set. The default is SHRLEVEL CHANGE ISOLATION CS.
CHANGE
Specifies that rows can be read, inserted, updated, and deleted from the table space or
partition while the data is being unloaded.
ISOLATION
Specifies the isolation level with SHRLEVEL CHANGE.
CS
Indicates that the Unload utility reads rows in cursor stability mode. With CS, the Unload utility
assumes CURRENTDATA(NO.)
UR
Indicates that uncommitted rows, if they exist, are unloaded. The unload operation is
performed with minimal interference from the other DB2 operations that are applied to the
objects from which the data is being unloaded.
REFERENCE
Specifies that during the unload operation, rows of the tables can be read, but cannot be
inserted, updated, nor deleted by other DB2 threads.
When you specify SHRLEVEL REFERENCE, the Unload utility drains writers on the table
space from which the data is to be unloaded. When data is unloaded from multiple partitions,
the drain lock will be obtained for all of the selected partitions in the UTILINIT phase.
The publications listed in this section are considered particularly suitable for a more detailed
discussion of the topics covered in this redbook.
IBM Redbooks
For information on ordering these publications, see “How to get IBM Redbooks” on page 334.
DB2 for z/OS and OS/390 Version 7 Using the Utilities Suite, SG24-6289
DB2 for z/OS and OS/390 Version 7 Performance Topics, SG24-6129
DB2 for z/OS and OS/390 Tools for Performance Management, SG24-6508
DB2 UDB Server for OS/390 and z/OS Version 7 Presentation Guide, SG24-6121
DB2 for z/OS DM Tools for Database Administration and Change Management,
SG24-6420-00
DB2 Web Query Tool Version 1.2, SG24-6832
A Practical Guide to DB2 UDB Data Replication V8, SG24-6828
DB2 Warehouse Management: High Availability and Problem Determination Guide,
SG24-6544
Large Objects with DB2 for z/OS and OS/390, SG24-6571
Other resources
These IBM publications are also relevant as further information sources:
DB2 UDB for OS/390 and z/OS Version 7 Utility Guide and Reference, SC26-9945-03
DB2 UDB for OS/390 and z/OS Version 7 Application Programming and SQL Guide,
SC26-9933
DB2 UDB for OS/390 and z/OS Version 7 Programming Guide and Reference for Java,
SC26-9932
DB2 UDB for OS/390 and z/OS Version 7 Administration Guide, SC26-9931-03
DB2 UDB Quick Beginnings for DB2 Servers Version 8, SC09-4836
DB2 UDB Administration Guide: Performance Version 8, SC09-4821
DB2 UDB Administrative API Reference, SC09-4824
DB2 UDB Data Movement Utilities Guide and Reference Version 8, SC09-4830
DB2 UDB Federated Systems Guide Version 8, SC09-4830
DB2 UDB Command Reference Version 8, SC09-4828
DB2 Connect User’s Guide Version 8, SC09-4835
DB2 High Performance Unload for z/OS Version 2 Release 1, SC27-1602
DB2 High Performance Unload for Multiplatforms Version 2 Release 1, SC27-1623-01
DB2 Data Export Facility for z/OS Version 1 Release 1, SC27-1466
DB2 Replication Guide and Reference, SC26-9920-00
You can also download additional materials (code samples or diskette/CD-ROM images) from
that site.
I M
IEEE 328 mainframe 4
IFREQ 122 MAXERR 40, 328
IGNOREFIELDS YES 70 MAXROWS 26
impact analysis 22 messages option 97
Index 337
using image copy 40
Unload from z/OS table space 41
Unload utility 10
Unload utility with DB2 for z/OS V7 34
Unload with field selection list 46
unloading compressed table space 40
unloading from a table space 41
unloading in parallel by partition 43
UQ55541 59, 247
UQ55542 59, 247
UQ72062 22
UR 329
USER 23, 120, 152
UTILINIT 35
UTILTERM 35
V
VARIABLE 23, 120, 151
vol-ser 325
Volume 214
VSAM 120
W
Warehouse Manager for UNIX, Windows 27
WEB Query tool for z/OS and Multiplatform 26
WHEN 68
WHEN clause 10, 34
WHEN option 40
WHERE 184
wrapper 304
WSF 14, 218
X
XML 26