The memory architecture of an Oracle database consists of the memoryarea allocated to the Oracle instance and database upon startup.. The memory architecture of DB2 UDB is slightly diffe
Trang 1Oracle to DB2 UDB Conversion Guide
by Whei-Jen Chen et al
ISBN:0738499455
IBM Redbooks © 2003 (448pages)
This informative guide describes how to migrate the database system from Oracle
to DB2 UDB Version 8.1 on AIX, Linux, and the Microsoft Windows platform It
presents the best practices in migration strategy and
planning, migration tools, and more.
Table of Contents
Oracle to DB2 UDB Conversion Guide Notices
Trang 3DB2 Universal Database (DB2 UDB) has long been
known for its technology leadership This IBM Redbook
is an informative guide that describes how to migrate the database system from Oracle to DB2 UDB Version 8.1 on AIX, Linux, and the Microsoft Windows platform This guide presents the best practices in migration
strategy and planning, migration tools, and practical migration examples It is intended for technical staff who are involved in an Oracle to DB2 UDB conversion project.
This Redbook provides migration planning guidelines, with step-by-step instructions for installing and using IBM Migration Toolkits (MTK) to port the database
objects and data from Oracle to DB2 UDB It illustrates with examples how to convert the stored procedures, functions, and triggers Application programming and conversion considerations are discussed along with the differences in features and functionality of the two
products.
In addition, you can find script conversion samples for data loading, database administration, and reports,
which are useful for DBAs The testing section provides procedures and tips for conversion testing and
database tuning.
Trang 4ISBN:0738499455
All rights reserved.
Note to U.S Government Users Restricted Rights Use, duplication or
Trang 5disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Trang 6This information was developed for products and services offered in theU.S.A
IBM may not offer the products, services, or features discussed in thisdocument in other countries Consult your local IBM representative forinformation on the products and services currently available in your area.Any reference to an IBM product, program, or service is not intended tostate or imply that only that IBM product, program, or service may beused Any functionally equivalent product, program, or service that doesnot 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 subjectmatter described in this document The furnishing of this document doesnot 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 PROVIDESTHIS 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 incertain transactions, therefore, this statement may not apply to you
This information could include technical inaccuracies or typographicalerrors Changes are periodically made to the information herein; thesechanges will be incorporated in new editions of the publication IBM maymake 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
Trang 7IBM may use or distribute any of the information you supply in any way itbelieves appropriate without incurring any obligation to you
Information concerning non-IBM products was obtained from the
suppliers of those products, their published announcements or otherpublicly available sources IBM has not tested those products and cannotconfirm the accuracy of performance, compatibility or any other claimsrelated to non-IBM products Questions on the capabilities of non-IBMproducts should be addressed to the suppliers of those products
This information contains examples of data and reports used in dailybusiness operations To illustrate them as completely as possible, theexamples include the names of individuals, companies, brands, and
products All of these names are fictitious and any similarity to the namesand 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 operatingplatforms 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 theapplication programming interface for the operating platform for which thesample programs are written These examples have not been thoroughlytested under all conditions IBM, therefore, cannot guarantee or implyreliability, 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
Trang 8Redbooks (logo) Everyplace® Rational®
The following terms are trademarks of other companies:
Trang 9Microsoft, 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
UNIX is a registered trademark of The Open Group in the United Statesand 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
Trang 10This IBM® Redbook provides procedures and examples of convertingOracle to DB2® UDB We focus on the technical considerations and
methodology involved in performing the database and application
conversion The laboratory examples are performed under Oracle 8i andDB2 UDB V8.1 However, the migration process and examples can beapplied to Oracle 7, 8, and 9i The redbook is organized as follows
Chapter 1 provides an overview of both Oracle and DB2 UDB tofacilitate the understanding of both architectures
Chapter 2 introduces the common process of migration and
porting, the planning process, and the available tools and
resources
Chapter 3 describes the IBM Migration Toolkits functions andinstallation procedures
Chapter 4 discuss and demonstrates the conversion of databaseobjects and the extraction and loading of data into a DB2 UDBdatabase using the IBM Migration Toolkit
Chapter 5 explores some tools and methods for manually
converting the triggers, store procedures, and functions It alsoprovide examples of implementing SQL features in DB2 UDB,and technics in building external procedures and functions usingC/C++ and Java™
Chapter 6 discusses the data conversion methods for deployingthe data from Oracle to DB2 database
Chapter 7 describes the application conversion from an Oracle to
a DB2 UDB environment including planning, Proc*C, OCI, Javaconversion, and package application migration such as SAP,PeopleSoft, and Siebel
Chapter 8 discusses the administration script conversion from anOracle environment to a DB2 UDB environment including data
Trang 11report tools available to DB2
Chapter 9 describes the test objectives and a generic testingmethodology that can be employed to test a migrated application
Trang 12This redbook was produced by a team of specialists from around theworld working at the International Technical Support Organization, SanJose Center
system administration Whei-Jen is an IBM Certified Solutions Expert inDatabase Administration and Application Development as well as an IBMCertified IT Specialist
competitive Oracle to DB2 migration initiatives Fadel is based in Dublin,Ohio
Trang 13the IBM Database Migration Team She is an IBM Certified SolutionsExpert who joined IBM at 1995 with experience in database applicationarchitecture and development During the 8 years Marina has been withDB2 Migration Team, she has assisted the customer in their migrationsfrom Microsoft® SQL Server, Sybase, or Oracle databases to DB2 UDB.She presented migration methodology at numerous DB2 technical
conferences and at SHARE She is also author of multiple articles and awhite paper on the DB2 migration subject
Stefan Hummel is an IT Specialist for competitive database migrations in
IBM, Germany He has more than 9 years of IT experience using a widerange of client and server platforms His experience includes applicationdevelopment as well as database design, implementation, and
Database on Windows NT®, UNIX, IBM iSeries™ server; and Oracle
database administration on Windows and UNIX platforms He is an IBMCertified Solutions Expert on Universal Database 8.1 Database
administration and Oracle Certified Professional on Oracle 8i Databaseadministration He trains exclusively on Oracle and DB2 for OS/390 andUniversal Database on Windows NT and UNIX at Cognizant
Ken Leonard is an Information Technology Specialist with IBM
Information Management group He has 14 years experience in the areas
of application development and database administration Before joiningIBM, he worked for Oracle Corporation for more than 7 years as a SeniorSystems Engineer and a consultant He became certified on Oracle 7.3 in1998
Art Sammartino is a Certified Consulting IT Software Specialist with the
Trang 14and Oracle databases to DB2 UDB He is also a co-author of the DB2
UDB V7.1 Porting Guide, SG24-6128.
Artur Wronski is a Advisory IT Specialist within IBM Software Group,
Poland He has more than nine years of experience in the IT Industry Heholds a master's degree in Knowledge Discovery in Databases, at
Warsaw Technical University His areas of expertise include DB2 UDBadministration, troubleshooting and tuning, as well as Business
Trang 16Join us for a two- to six-week residency program! Help write an IBMRedbook dealing with specific products or solutions, while getting hands-
on experience with leading-edge technologies You'll team with IBMtechnical professionals, Business Partners and/or customers
Your efforts will help increase product acceptance and customer
satisfaction As a bonus, you'll develop a network of contacts in IBMdevelopment 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
Trang 17Your comments are important to us!
We want our Redbooks™ to be as helpful as possible Send us yourcomments about this or other Redbooks in one of the following ways:
Dept QXXE Building 80-E2
650 Harry RoadSan Jose, California 95120-6099
Trang 18Chapter 1: Introduction
Trang 19Since migrating from Oracle to DB2 UDB requires a certain level of
knowledge in both environments, the purpose of this chapter is to
introduce the architectural overview of both Oracle and DB2 UDB This ismeant to facilitate the understanding of both architectures, taking intoconsideration that the reader may be an Oracle or a DB2 DBA
ReplicatingPartitioned database architecture
Trang 20In the era of Information on demand, IBM Information management
software offers a wide range of products to accommodate different
business needs and technical requirements in order to provide customerswith a robust and scalable enterprise wide solution
DB2 UDB offers database solutions that run on all platforms includingWindows servers, AIX®, Sun, HP-UX, Linux, AS/400®, OS/390 and
bit environments DB2 UDB product family comprises a variety of
z/OS® Furthermore, DB2 UDB technologies support both 32-bit and 64-packages provide customers choices based on the business need Thefollowing lists the DB2 UDB product offerings for Linux, UNIX, and
Microsoft Windows:
DB2 UDB Enterprise Server Edition (ESE)
DB2 UDB ESE is designed to meet the database server needs ofmidsize to large businesses ESE's high scalability, availability,and reliability features provide customers an ideal database
management system for all types of transactions:
The Database Partitioning Feature (DPF)
The Database Partitioning Feature is a licensing optionthat allows ESE customers to partition a database within
a single system or across a cluster of systems The DPFcapability provides the customer with multiple benefitsincluding scalability to support very large databases, orcomplex workloads and increased parallelism for
administration tasks
DB2 Workgroup Server Edition (WSE)
This Edition is designed for deployment at a departmental level or
in a small business environment with a small number of users Itcan be deployed on a server with up to 4 CPUs
Trang 21This product offers a package for single application developer todesign and build an application
extender, which enables storing and retrieving data in the form of XMLdocuments; Spatial extender to manipulate spatial data; and Audio andVideo extenders, which handle both audio and video files respectively.IBM also provides federated technologies to extend the functionality of
Trang 22objects in many different databases such as Oracle and Sybase with asingle query
In addition, DB2 Connect™ Editions offer you the capability to extend yourenterprise system to access the legacy system
Appendix A, "DB2 UDB product overview" on page 335 provides a
detailed description of the capabilities and features of DB2 UDB
products
Trang 23Before getting into conversion process, a clear understanding betweenthe terminologies used in Oracle and DB2 UDB help the readers tounderstand and map each terminology between Oracle and DB2 UDB.This section discusses some of the terminologies, and a mapping
between these terminologies is given
1.2.1 Terminology mapping
Table 1-1 provides a quick reference of commonly used terminologies inOracle and DB2 UDB More information about the terminology mapping
is provided in Appendix E, "Terminology mapping" on page 393
Trang 25It is very useful to understand the differences between Oracle's
architecture and that of DB2 UDB before attempting the Oracle to DB2UDB migration process Both products include their own memory
architecture, back ground processes, database related files, and differentconfiguration files Both Oracle and DB2 UDB consist of an instance andthe database(s) attached to that instance This section provides a generaldescription of the architectures of each vendor
database server through a programming interface The memory units areallocated for database managers, database, and application
Trang 26Figure 1-2: DB2 architecture overview
The following section discusses both architectures, detailing memorycomponents and background processes of both databases
1.3.1 Memory architecture
This section discusses the memory architecture in Oracle and DB2 UDB.Oracle and DB2 UDB allocate and uses memory for instance and
database operation There are various memory structures used for
different process This section gives a broader overview about how
memory is allocated and used in a simple Oracle and DB2 UDB server
The memory architecture of an Oracle database consists of the memoryarea allocated to the Oracle instance and database upon startup Theamount of memory allocated is controlled by parameters defined in theOracle configuration file
The memory architecture of DB2 UDB is slightly different than Oracle's.Unlike Oracle, the DB2 UDB server can run multiple databases underone instance and hence has configuration files at both the instance level(Database Manager configuration file) and at the database level
(database configuration file)
Trang 27Oracle uses memory to run the code and share data among the users.The two basic components of the Oracle memory structure are the
Program Global Area (PGA) and the System Global Area (SGA) Figure1-3 shows the primary memory architecture of an Oracle server
Figure 1-3: Oracle memory architecture
The PGA is associated with the Server process and contains the dataand control information For the dedicated server configuraiton, the
primary contents of the PGA are the sort area, session information,
cursor state and stack space This is a non sharable memory which
writable only by the server process The PGA are allocated whenever aserver process starts and the total size of the PGA is controlled by the
PGA_AGGREGATE_TARGET initialization parameter in version 9i.
The SGA is the shared memory region allocated for the entire OracleInstance The SGA is a group of shared memory structures in which thebasic components comprises of the shared pool, data buffer cache andthe Redo log buffer The shared pool contains the library cache and datadictionary cache The library cache holds the SQL statement text, theparsed SQL statement and the execution plan The data dictionary cachecontains reference information about tables, views, object definitions andobject privileges The shared pool size is controlled by
SHARED_POOL_SIZE initialization parameter The data buffer cache
stores the most recently used Oracle data blocks Oracle reads the datablocks from the datafiles and places it in data buffers before processingthe data The number of buffers allocated is controlled by
Trang 28The redo log buffer is circular buffer that contains redo entries of the
change information made to the database These redo log buffers arewritten into the redo log files and is required for the database recovery
The size of the redo log buffers are controlled by the LOG_BUFFER
initialization parameter The other memory structures of the SGA includethe large pool and the Java pool used for backup process and Java
objects respectively For a shared server configuration in version 9i (ormulti threaded server in 8i) the session information and the sort areas are
in SGA instead of PGA
DB2 UDB
The three primary memory structures in DB2 UDB are the Instance
Shared Memory (also known as Database Manager shared memory), theDatabase Shared memory and the Application Shared Memory Figure 1-
4 shows the basic memory architecture of a DB2 server
Figure 1-4: DB2 UDB memory architecture
Instance Shared Memory is allocated when the database is started Allother memory is attached or allocated from the instance shared memory
Trang 29time This memory is shared by all the applications that might connect tothe database as well as the database EDU's (Engine Dispatchable Units)
Trang 30a non-partitioned database environment where intra-partition is enabled
or if the connection concentrator is enabled This memory is used by theconnecting agents to execute the work requested by the clients The
database manager configuration parameter MAX_CONNECTIONS limits
the maximum number of applications that connects the database which inturn sets the upper limit for the maximum Application Shared Memoryallocated
Oracle
There are two major types of Oracle process: the user processes and thebackground processes (see Figure 1-5)
Figure 1-5: Oracle process architecture
User process
Oracle creates a user process when the user or application connects tothe database For each user process, a server process is created by
Oracle to handle the user process request to Oracle instance This
Trang 31server process are combined to a single process The function of theserver process is to parse the SQL statement, read the Oracle data
blocks from the datafile to the data buffer, and return the result set to theclient
Log writer (LGWR): This is the process that handles writing data
from the redo log buffer cache onto the redo log files
System monitor (SMON): This process has two functions First,
it performs an instance recovery when the Oracle instance fails,and second it coalesces smaller fragments of disk space
together
Process Monitor (PMON): This process cleans up any
remaining Oracle processes resulting from a failing user process.Furthermore, it rollbacks any uncommitted transactions that wereperformed by the user
Ckeckpoint (CKPT): This process writes log sequence numbers
to the database headers and control files
DB2 UDB
For a DB2 instance to start and run, several process are created andinteract with each other, which maintains the applications connected andthe database created on the instance There are several backgroundprocesses in DB2 that are pre-started, and some start on a need-only
Trang 32processes
DB2 UDB background processes
The DB2 server activities are performed by Engine Dispatchable Units(EDU) that are defined on a Windows environment as threads and asbackground processes on both UNIX and Linux systems
Such as Oracle, there are many background processes dedicated to theoperation of the DB2 instance As mentioned in the previous paragraph,some DB2 background processes are started with the instance, andothers are initialized when the database is activated by a connection
Figure 1-6 shows the necessary background processors of the DB2 UDBserver at the instance, application, and database level In the followingsections, we discuss some of the important process in each level of DB2UDB
Trang 33path when the LOGRETAIN database configuration parameter isset to ON, and the USEREXIT parameter is set to OFF This issimilar to the optional Archiver log process (ARCn) process inOracle and is enabled when the database is set in ARCHIVELOGmode
DB2 page cleaner (db2pclnr): This process is presented to
make room in the buffer pool before prefetchers read pages ondisk storage and move into the buffer pool Page cleaners areindependent of the application agents that look for and write outpages from and to the buffer pool to ensure that there is room inthe buffer pool This is equivalent to DBWR process in Oracle
Trang 34works with the db2agent process when intra-partition parallelism
is enabled
Trang 35currently performing work This process is used when enablingSMP parallelism, which means having more processes achievingthe same task In order to enable this feature in DB2, we must setthe intra-parallelism database parameter to true
The db2agent process, with or without the combination sub agents,
performs the similar function of the Oracle server process
1.3.3 Files and directory structure
This section discusses about important files and the common directorystructure used in Oracle and DB2 UDB A instance and database
requires a number of files like datafiles, configuration files, log files etc tooperate and store data This section looks at some of these importantfiles and gives an overview of its uses The directory structure gives anidea of how a product is installed and how some files are placed on thisstructure
Oracle
Every Oracle instance needs a set of files to comprise itself and operate.These files include the datafiles, redo log files, control file, parameter file,the alert log file, and the password file as shown in the Figure 1-7 The
physical files to mount a tablespace in Oracle are called datafiles The
datafiles stores the data, index and rollback segments of the Oracle
database Oracle maintains the database transactions in a transactionallog files called redo log files There should be at least one set of redo logfiles created for a database to operate Every Oracle database has acontrol file The control file contains the entries that describes the
physical structure of the database Every time a instance is started, thecontrol file is used to identify the datafiles and redo log files to start thedatabase
Trang 36Figure 1-7: Oracle database files
The initialization file or the parameter file is used by the Oracle instanceduring startup The file contains the values for many initialization
parameters used to allocate memory and start the process for the
instance to run The password file is a security file used for authenticatingwhich users are permitted to start up or shut down an instance or performother privileged maintenance on a database with SYSDBA or SYSOPER(8i) privileges and additionally OSDBA or OSOPER (9i) privileges Thealert log file is the diagnostics file used by the Oracle instance to recordall the dump information of the database like internal errors, block
corruption errors, etc
Oracle installation follows Optimal Flexible Architecture (OFA) standards
in creating the directories and placing the files The OFA is a set of filenaming and placement standards Oracle recommends following OFAstandards Using OFA, the Oracle installation process places the Oraclesoftware in $ORACLE_BASE\ORACLE_HOME and datafiles in
$ORACLE_BASE\oradata directory Figure 1-8 shows a sample
installation directory structure on the 8i version of Oracle The
initialization file and the password file reside under dbs path in the UNIXserver and database directory in Windows server The bin directory
contains all the executable binary files
Trang 37about these files
DB2 UDB
The primary files and directories for a DB2 instance and database includethe DMS containers, SMS containers (directory or path), DBM cfg file, DBcfg file, the Transaction log files, and the db2diag.log file This structure isshown in Figure 1-9 The DBM cfg file is created per DB2 instance andcontains the configuration parameters and values This file resides underthe sqllib directory of the instance home named as db2systm This can
be related to the initialization parameter file in Oracle but unlike Oraclethis is not a text file rather a binary file and can be updated only using
UPDATE DBM CFG command
Trang 38Figure 1-9: DB2 Instance and database files
The DB cfg file the configuration file for each database which stores thedatabase configuration values This file is stored with the name
DIAGPATH DBM configuration parameter identifies the location of
db2diag.log
Figure 1-10 shows the default directory structure for a simple CREATE
DATABASE command with no tablespace options specified By default thetablespace created will be SMS containers, and the log files will be
created in the SQLLOGDIR directory, which can be changed by updatingthe NEWLOGPATH DB cfg parameter
Trang 39shows the installation directory structure for Windows environment andsqllib directory structure for UNIX environment
Figure 1-11: DB2 UDB directory structure
The adm directory consists of instance administration commands, licensemanagement commands and other commands The backup directory
Trang 40directory contains various database bind files The db2dump directoryholds db2diag.log file and other trace files All the external stored
procedures and routines executable programs are stored under functiondirectory The Java directory contains the JDBC driver files The samplesdirectory contains all the program samples that comes shipped with DB2software
Configuration files
Since the Oracle instance can only support one database, its backgroundprocesses are enabled as soon as the instance is started Therefore,Oracle has one configuration file which is used to configure and tune thedatabase
The DB2 instance however can support multiple databases, and
therefore, consists of an instance level shared memory and a databaseshared memory running on the server side Starting the DB2 instance willonly start the instance level processes Database level processes such
as those that control transactional processing tasks, logging, and writing
to containers on disk are only enabled when the database itself is
activated by a user or an application connection
Therefore, there are two files controlling the configuration and tuning ofthe DB2 server and database The first file is used to configure and tunethe DB2 server at the instance level is called the Database Manager
Configuration (DBM CFG) file The second is a database level
configuration file (DB CFG) used to control database level parameters
1.3.4 Data Dictionary and Catalog
Every RDBMS has a form of metadata that describes the database andits objects Essentially, the metadata contains information about the
logical and physical structure of the database, integrity constraints, usersand schema information, authorization, and privilege information, etc
In the Oracle database, this metadata is stored in a set of read-only