Front Cover Microsoft SQL Server To IBM DB2 UDB Conversion Guide

Transcription

Front coverMicrosoft SQL Server toIBM DB2 UDBConversion GuideComplete guide to convert fromMicrosoft SQL Server to IBM DB2 UDBApplication enrichment throughadvanced DB2 UDB featuresApplication conversionwith detailed examplesWhei-Jen ChenAlain FisherStefan HummelShailendra KishoreWei Bin TeahTed Wassermanibm.com/redbooks

International Technical Support OrganizationMicrosoft SQL Server to IBM DB2 UDBConversion GuideJune 2005SG24-6672-00

Note: Before using this information and the product it supports, read the information in“Notices” on page xxi.First Edition (June 2005)This edition applies to DB2 UDB Version 8.2, Microsoft SQL Server 2000, and Windows 2000Server. Copyright International Business Machines Corporation 2005. All rights reserved.Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADPSchedule Contract with IBM Corp.

ContentsFigures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiTables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xixNotices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiTrademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiiThe team that wrote this redbook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxivAcknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvBecome a published author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxviComments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviiChapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 DB2 Universal Database - a high-level overview . . . . . . . . . . . . . . . . . . . . 21.2 Project environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.3 IBM migration offering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.3.1 DB2 UDB promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.3.2 DB2 migration services and support . . . . . . . . . . . . . . . . . . . . . . . . . . 9Chapter 2. Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.1 Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.1.1 SQL Server instance definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.1.2 DB2 UDB instance definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.2 Memory allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.2.1 SQL Server memory allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.2.2 DB UDB memory allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.3 Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.3.1 SQL Server process model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.3.2 DB2 UDB process model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.4 Allocating disk space. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.4.1 SQL Server disk allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.4.2 DB2 UDB disk allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.5 Transaction logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.5.1 SQL Server transaction log overview . . . . . . . . . . . . . . . . . . . . . . . . 202.5.2 DB2 UDB transaction log overview . . . . . . . . . . . . . . . . . . . . . . . . . . 202.6 Query optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.6.1 SQL Server query optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.6.2 DB2 UDB query optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Copyright IBM Corp. 2005. All rights reserved.iii

2.7 Parallelism. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.7.1 SQL Server parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.7.2 DB2 UDB parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.8 Message logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.8.1 SQL Server error logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.8.2 DB2 error logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.9 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.9.1 SQL Server security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.9.2 DB2 UDB Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.9.3 Security enhancements in V8.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.10 High availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.10.1 SQL Server high availability strategies . . . . . . . . . . . . . . . . . . . . . . 302.10.2 DB2 high availability strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Chapter 3. DB2 UDB administration tools . . . . . . . . . . . . . . . . . . . . . . . . . 313.1 GUI tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323.1.1 Control Center. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323.1.2 Command Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333.1.3 SQL Assist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343.1.4 Visual Explain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353.1.5 Task Center. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363.1.6 Journal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373.1.7 Health Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383.1.8 Development Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393.1.9 Configuration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.1.10 Information Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.1.11 License Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.1.12 Replication Center. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.1.13 Data Warehouse Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443.1.14 Information Catalog Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.1.15 Satellite Administration Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.1.16 Web administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.2 Wizards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493.3 Advisors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503.4 Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523.5 Utilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.5.1 Maintaining database integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.5.2 Throttling utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573.5.3 Validating a backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583.5.4 DDL extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583.6 Performance monitor integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613.7 Optional tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623.7.1 DB2 Performance Expert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62ivMicrosoft SQL Server to IBM DB2 UDB Conversion Guide

3.7.23.7.33.7.43.7.53.7.6DB2 Recovery Expert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62DB2 High Performance Unload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63DB2 Test Database Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63DB2 Table Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64DB2 Web Query Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64Chapter 4. SQL considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654.1 SQL standard compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664.2 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664.2.1 Data type mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664.2.2 Strong type casting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664.2.3 ROWVERSION data type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674.2.4 NULL value considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694.2.5 Large object (LOB) considerations . . . . . . . . . . . . . . . . . . . . . . . . . . 694.3 Date and time considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704.3.1 Retrieving date and time values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714.3.2 Date and time conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714.3.3 Date and time arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734.3.4 Examining date and time components . . . . . . . . . . . . . . . . . . . . . . . 744.3.5 Additional date and time examples . . . . . . . . . . . . . . . . . . . . . . . . . . 754.4 String considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 764.5 Case sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774.6 SQL language syntax and semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794.6.1 SELECT statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794.6.2 SELECT INTO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814.6.3 INSERT statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824.6.4 UPDATE and DELETE statements . . . . . . . . . . . . . . . . . . . . . . . . . . 844.6.5 TRUNCATE TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 844.6.6 ANSI joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854.6.7 ORDER BY and GROUP BY clauses . . . . . . . . . . . . . . . . . . . . . . . . 874.6.8 Top n clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874.6.9 Cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884.7 Built-in SQL functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904.8 System catalog queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914.8.1 Catalog interrogation and instance/database metadata . . . . . . . . . . 924.8.2 System table mapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 944.8.3 Authorizations on system catalog tables . . . . . . . . . . . . . . . . . . . . . . 954.9 Transact-SQL to SQL PL translation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 964.9.1 EXECUTE string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 974.9.2 PRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 984.9.3 @@ERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 994.9.4 RAISERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1014.9.5 @@SQLSTATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101Contentsv

4.9.6 @@ROWCOUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024.9.7 @@TRANCOUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024.10 XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1034.10.1 FOR XML statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1044.10.2 OPENXML statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1134.11 SQL limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117Chapter 5. Planning for a conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1195.1 Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1205.1.1 Performing a porting assessment . . . . . . . . . . . . . . . . . . . . . . . . . . 1205.1.2 Understanding and selecting conversion tools . . . . . . . . . . . . . . . . 1215.1.3 Estimating the effort required . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1225.1.4 Planning the conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1235.1.5 Becoming educated on DB2 UDB. . . . . . . . . . . . . . . . . . . . . . . . . . 1235.1.6 Environment preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1245.2 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1245.2.1 Converting the database structure . . . . . . . . . . . . . . . . . . . . . . . . . 1245.2.2 Converting database objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1265.2.3 Porting additional database components and products . . . . . . . . . 1265.2.4 Modifying the application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1275.2.5 Modifying the database interface . . . . . . . . . . . . . . . . . . . . . . . . . . 1285.2.6 Migrating the data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1315.3 Post-conversion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1325.3.1 Performance tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1325.3.2 Utilizing additional DB2 utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1345.3.3 Defining a maintenance strategy. . . . . . . . . . . . . . . . . . . . . . . . . . . 1345.4 Additional references. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135Chapter 6. The IBM DB2 Migration Toolkit for SQL Server . . . . . . . . . . . 1376.1 MTK technical overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1396.1.1 Supported operating system and versions . . . . . . . . . . . . . . . . . . . 1396.1.2 Hardware requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1396.1.3 MTK software requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1396.1.4 Where to install MTK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1396.2 MTK setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1406.3 Using MTK. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1426.3.1 MTK GUI interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1426.3.2 Migration tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1436.3.3 The MTK SQL Translator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148Chapter 7. Database structure conversion . . . . . . . . . . . . . . . . . . . . . . . . 1517.1 Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1527.2 Table spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1527.3 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153viMicrosoft SQL Server to IBM DB2 UDB Conversion Guide

7.3.1 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1547.3.2 IDENTITY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1547.3.3 Computed columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1557.3.4 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1567.4 Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1587.5 Schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1597.6 Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1607.7 Privileges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1607.8 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1627.8.1 Database structure conversion using MTK . . . . . . . . . . . . . . . . . . . 1627.8.2 Manually converting database structure . . . . . . . . . . . . . . . . . . . . . 165Chapter 8. Data and script migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1698.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1708.2 A typical data migration process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1708.2.1 Migrating a subset of data using MTK. . . . . . . . . . . . . . . . . . . . . . . 1718.2.2 Verifying referential integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1748.3 Using Export, Import, and Load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1758.4 Using WebSphere Information Integrator . . . . . . . . . . . . . . . . . . . . . . . . 1778.4.1 Accessing SQL Server data from DB2 UDB . . . . . . . . . . . . . . . . . . 1788.4.2 Replicating data from SQL Server to DB2 UDB . . . . . . . . . . . . . . . 1808.5 Using other tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1828.6 Converting scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182Chapter 9. Converting database objects. . . . . . . . . . . . . . . . . . . . . . . . . . 1859.1 Temporary tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1869.1.1 Private temporary tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1879.1.2 Global temporary tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1889.1.3 Additional information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1889.2 Stored procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1899.2.1 Temporary stored procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1909.2.2 Extended stored procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1909.2.3 Remote procedure calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1919.2.4 @@PROCID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1919.2.5 Simple conversion example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1929.2.6 Default parameter values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1939.2.7 Passing parameter values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1969.2.8 Returning a cursor to the caller . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1999.2.9 Exception handling and transaction control . . . . . . . . . . . . . . . . . . 2029.2.10 Additional information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2089.3 User defined functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2089.3.1 Scalar functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2099.3.2 Table functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Contentsvii

9.3.3 Overcoming inline SQL PL limitations in user defined functions . . . 2119.3.4 Additional information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2149.4 Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2159.4.1 Accessing transition values in triggers . . . . . . . . . . . . . . . . . . . . . . 2169.4.2 Simple conversion example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2169.4.3 IF UPDATE(column) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2189.4.4 Overcoming inline SQL PL limitations in triggers . . . . . . . . . . . . . . 2199.4.5 INSTEAD OF triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2229.4.6 Additional information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Chapter 10. Application conversion considerations . . . . . . . . . . . . . . . . 22510.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22610.2 Converting to DB2 UDB compatible SQL syntax . . . . . . . . . . . . . . . . . 22610.2.1 Using MTK’s SQL Translator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22610.2.2 Manual conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22810.3 Identifying transaction differences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22810.4 Identifying locking and lock escalation differences . . . . . . . . . . . . . . . . 22910.4.1 Types of locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23010.4.2 Lock escalation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23310.4.3 Deadlock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23310.5 Identifying isolation level differences. . . . . . . . . . . . . . . . . . . . . . . . . . . 23410.5.1 Repeatable Read (RR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23610.5.2 Read Stability (RS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23710.5.3 Cursor Stability (CS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23710.5.4 Uncommitted Read (UR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23810.6 Identifying and modifying database interfaces . . . . . . . . . . . . . . . . . . . 23810.6.1 ActiveX Data Objects .NET (ADO.NET) interfaces . . . . . . . . . . . . 23910.6.2 ActiveX Data Object (ADO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24210.6.3 Java Database Connectivity (JDBC) . . . . . . . . . . . . . . . . . . . . . . . 24910.6.4 Embedded SQL for C (ESQL/C) . . . . . . . . . . . . . . . . . . . . . . . . . . 24910.7 Integrating DB2 UDB in Integration Development Environment (IDE) . 25310.7.1 Microsoft .NET add-in (Visual Studio) . . . . . . . . . . . . . . . . . . . . . . 25310.7.2 IBM WebSphere Studio Application Developer. . . . . . . . . . . . . . . 25510.8 Approaching packaged application migration . . . . . . . . . . . . . . . . . . . . 25610.8.1 SAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25710.8.2 Siebel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260Chapter 11. Performing administrative tasks in DB2 UDB . . . . . . . . . . . 26311.1 Working with instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26411.1.1 Create, drop, and list instances. . . . . . . . . . . . . . . . . . . . . . . . . . . 26411.1.2 Attaching / switching instances . . . . . . . . . . . . . . . . . . . . . . . . . . . 26511.1.3 Start, stop, and quiesce instances . . . . . . . . . . . . . . . . . . . . . . . . 26611.1.4 Configure instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266viiiMicrosoft SQL Server to IBM DB2 UDB Conversion Guide

11.2 Working with databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26711.2.1 Create, drop, and list databases . . . . . . . . . . . . . . . . . . . . . . . . . . 26711.2.2 Activate and terminate databases. . . . . . . . . . . . . . . . . . . . . . . . . 27011.2.3 Connect, disconnect, and quiesce databases. . . . . . . . . . . . . . . . 27011.2.4 Configure databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27111.2.5 List and force off applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27211.3 Managing database storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27211.3.1 Table spaces and containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27311.3.2 Monitoring table space and container storage . . . . . . . . . . . . . . . 28411.3.3 Transaction logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28911.4 Working with buffer pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29411.5 Task Center and the DB2 Tools Catalog. . . . . . . . . . . . . . . . . . . . . . . . 29611.5.1 DB2 Administration Server and Tools Catalog Database . . . . . . . 29711.5.2 Task Center and Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29811.6 Backup, recovery, and log administration . . . . . . . . . . . . . . . . . . . . . . . 30511.6.1 Automatic backup maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . 30611.6.2 Backup using throttling mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30811.6.3 Log file inclusion in backup images. . . . . . . . . . . . . . . . . . . . . . . . 30811.6.4 Backup compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31011.6.5 Automated log file management . . . . . . . . . . . . . . . . . . . . . . . . . . 31111.6.6 Undo management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31211.7 High availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31311.7.1 Failover clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31311.7.2 HADR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31311.7.3 Log mirroring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32711.7.4 Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32811.7.5 Online split mirror and suspended I/O support . . . . . . . . . . . . . . . 32911.8 REORG and RUNSTATS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33011.8.1 Database reorganization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33011.8.2 Database statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335Chapter 12. Post-conversion tuning considerations . . . . . . . . . . . . . . . . 33912.1 Performance tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34012.2 Quick-start tips for performance tuning . . . . . . . . . . . . . . . . . . . . . . . . . 34012.2.1 Design Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34112.2.2 Configuration Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34212.2.3 ACTIVATE DATABASE command . . . . . . . . . . . . . . . . . . . . . . . . 34512.2.4 RUNSTATS and REORG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34612.3 Configuring automatic maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . 34612.4 Other performance tuning advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35012.4.1 Table spaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35012.4.2 Physical placement of database objects . . . . . . . . . . . . . . . . . . . . 35212.4.3 Buffer pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355Contentsix

12.4.4 Large transactions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35812.4.5 Process tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36312.5 Data access strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36412.5.1 Indexing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Microsoft SQL Server to IBM DB2 UDB Conversion Guide Whei-Jen Chen Alain Fisher Stefan Hummel Shailendra Kishore Wei Bin Teah Ted Wasserman Complete guide to convert from Microsoft SQL Server to IBM DB2 UDB Application enrichment through advanced DB2 UDB features Application conversion with detailed examples Front cover