Db2 11 for z/OS: Administration Guide - IBM › support › knowledgecenter ›...

730
Db2 11 for z/OS Administration Guide IBM SC19-4050-07

Transcript of Db2 11 for z/OS: Administration Guide - IBM › support › knowledgecenter ›...

  • Db2 11 for z/OS

    Administration Guide

    IBM

    SC19-4050-07

  • Notes

    Before using this information and the product it supports, be sure to read the general information under"Notices" at the end of this information.

    Subsequent editions of this PDF will not be delivered in IBM Publications Center. Always download thelatest edition from PDF format manuals for Db2 11 for z/OS (Db2 Home).

    2020-06-17 edition

    This edition applies to Db2® 11 for z/OS® (product number 5615-DB2), Db2 11 for z/OS Value Unit Edition (productnumber 5697-P43), and to any subsequent releases until otherwise indicated in new editions. Make sure you are usingthe correct edition for the level of the product.

    Specific changes are indicated by a vertical bar to the left of a change. A vertical bar to the left of a figure captionindicates that the figure has changed. Editorial changes that have no technical significance are not noted.© Copyright International Business Machines Corporation 1982, 2020.US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract withIBM Corp.

    https://www.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/home/src/tpc/db2z_pdfmanuals.html

  • Contents

    About this information......................................................................................... xvWho should read this information..............................................................................................................xvDb2 Utilities Suite for z/OS.........................................................................................................................xvTerminology and citations......................................................................................................................... xviAccessibility features for Db2 11 for z/OS................................................................................................xviHow to send your comments....................................................................................................................xviiHow to read syntax diagrams...................................................................................................................xvii

    Part 1. Designing and implementing Db2 databases............................................... 1

    Chapter 1. Database objects and relationships.......................................................................................... 3Logical database design with the entity-relationship model ............................................................... 3

    Modeling your data........................................................................................................................... 3Recommendations for logical data modeling.................................................................................. 4Practical examples of data modeling............................................................................................... 5Entities for different types of relationships......................................................................................5Entity attributes ................................................................................................................................7Entity normalization.......................................................................................................................... 8

    Logical database design with Unified Modeling Language..................................................................12Physical database design.....................................................................................................................13

    Denormalization of tables...............................................................................................................14Views to customize what data users see....................................................................................... 15Indexes on table columns.............................................................................................................. 16Hash access on tables.................................................................................................................... 16Maintaining archive data.................................................................................................................17

    Chapter 2. Implementing your database design...................................................................................... 19Implementing Db2 databases............................................................................................................. 19

    Creating Db2 databases................................................................................................................. 19Dropping Db2 databases................................................................................................................ 20

    Implementing Db2 storage groups......................................................................................................20Advantages of storage groups........................................................................................................20Creating Db2 storage groups..........................................................................................................22Enabling SMS to control Db2 storage groups................................................................................ 22Deferring allocation of Db2-managed data sets............................................................................23How Db2 extends data sets............................................................................................................23Db2 space allocation...................................................................................................................... 25Managing Db2 data sets with DFSMShsm......................................................................................28Managing your own data sets.........................................................................................................33Defining index space storage......................................................................................................... 37Creating EA-enabled table spaces and index spaces....................................................................37

    Implementing Db2 table spaces..........................................................................................................38Table space types and characteristics in Db2 for z/OS................................................................. 39Implicitly defined table spaces...................................................................................................... 48Creating table spaces explicitly......................................................................................................49Creating partition-by-range table spaces...................................................................................... 53Creating partition-by-growth table spaces.................................................................................... 54EA-enabled table spaces and index spaces.................................................................................. 55

    Implementing Db2 tables.................................................................................................................... 55Creating base tables....................................................................................................................... 56

    iii

  • Guidelines for table names.............................................................................................................56Creating tables that use hash organization (deprecated)............................................................. 56Creating temporary tables..............................................................................................................58Creating temporal tables................................................................................................................ 63Creating materialized query tables................................................................................................ 74Creating tables partitioned by data value ranges.......................................................................... 74Nullable partitioning columns........................................................................................................ 75Creating a clone table .................................................................................................................... 76Creating an archive table................................................................................................................78

    Implementing Db2 views..................................................................................................................... 78Creating Db2 views......................................................................................................................... 79Guidelines for view names............................................................................................................. 80Querying views that reference temporal tables.............................................................................80How Db2 inserts and updates data through views........................................................................ 81Dropping Db2 views........................................................................................................................82

    Implementing Db2 indexes..................................................................................................................82Creating Db2 indexes......................................................................................................................82Guidelines for defining indexes...................................................................................................... 83How Db2 implicitly creates an index..............................................................................................84

    Implementing Db2 schemas................................................................................................................85Creating a schema by using the schema processor...................................................................... 85Processing schema definitions.......................................................................................................86

    Loading data into Db2 tables............................................................................................................... 86Loading data with the LOAD utility................................................................................................. 87Loading data by using the INSERT statement............................................................................... 89Loading data from DL/I...................................................................................................................91

    Implementing Db2 stored procedures................................................................................................ 91Creating stored procedures............................................................................................................92Dropping stored procedures...........................................................................................................93

    Implementing Db2 user-defined functions......................................................................................... 94Creating user-defined functions.....................................................................................................94Deleting user-defined functions.....................................................................................................95

    Estimating disk storage for user data.................................................................................................. 95General approach to estimating storage........................................................................................96Calculating the space required for a table .................................................................................... 98Calculating the space required for an index................................................................................ 101

    Chapter 3. Altering your database design...............................................................................................107Using the catalog in database design................................................................................................107

    Retrieving catalog information about Db2 storage groups......................................................... 107Retrieving catalog information about a table.............................................................................. 108Retrieving catalog information about partition order..................................................................108Retrieving catalog information about aliases.............................................................................. 109Retrieving catalog information about columns............................................................................109Retrieving catalog information about indexes.............................................................................110Retrieving catalog information about views................................................................................ 111Retrieving catalog information about authorizations.................................................................. 111Retrieving catalog information about primary keys.................................................................... 112Retrieving catalog information about foreign keys......................................................................112Retrieving catalog information about check pending..................................................................113Retrieving catalog information about check constraints.............................................................113Retrieving catalog information about LOBs................................................................................. 114Retrieving catalog information about user-defined functions and stored procedures.............. 115Retrieving catalog information about triggers............................................................................. 115Retrieving catalog information about sequences........................................................................116Adding and retrieving comments................................................................................................. 116Verifying the accuracy of the database definition....................................................................... 117

    Altering Db2 databases......................................................................................................................117

    iv

  • Altering Db2 storage groups.............................................................................................................. 117Letting SMS manage your Db2 storage groups............................................................................118Adding or removing volumes from a Db2 storage group.............................................................119Migrating existing data sets to a solid-state drive.......................................................................120

    Altering table spaces......................................................................................................................... 120Changing the logging attribute..................................................................................................... 122Changing the space allocation for user-managed data sets....................................................... 123Dropping and re-creating a table space to change its attributes................................................124Redistributing data in partitioned table spaces...........................................................................125Increasing partition size............................................................................................................... 127Altering a page set to contain Db2-defined extents....................................................................128Converting partitioned (non-UTS) table spaces to partition-by-range universal table spaces. 128Converting table spaces to use table-controlled partitioning.....................................................129

    Altering Db2 tables............................................................................................................................ 132Adding a column to a table...........................................................................................................133Specifying a default value when altering a column..................................................................... 135Altering the data type of a column...............................................................................................135Altering a table for referential integrity....................................................................................... 144Adding or dropping table check constraints................................................................................148Adding partitions.......................................................................................................................... 149Altering partitions......................................................................................................................... 151Adding XML columns.................................................................................................................... 159Altering tables for hash access (deprecated).............................................................................. 160Altering the size of your hash spaces (deprecated).................................................................... 162Adding a system period and system-period data versioning to an existing table......................163Adding an application period to a table....................................................................................... 165Manipulating data in a system-period temporal table................................................................ 165Altering materialized query tables...............................................................................................166Altering the assignment of a validation routine...........................................................................167Altering a table to capture changed data.....................................................................................168Changing an edit procedure or a field procedure........................................................................ 169Altering the subtype of a string column.......................................................................................169Altering the attributes of an identity column...............................................................................170Changing data types by dropping and re-creating the table....................................................... 170Moving a table to a table space of a different page size..............................................................174

    Altering Db2 views............................................................................................................................. 174Altering views by using the INSTEAD OF trigger......................................................................... 175Changing data by using views that reference temporal tables................................................... 175

    Altering Db2 indexes..........................................................................................................................176Alternative method for altering an index..................................................................................... 177Adding columns to an index......................................................................................................... 177Altering how varying-length index columns are stored...............................................................179Altering the clustering of an index............................................................................................... 180Dropping and redefining a Db2 index...........................................................................................181Reorganizing indexes....................................................................................................................182

    Pending data definition changes....................................................................................................... 183Materializing pending definition changes.................................................................................... 186Restrictions for changes to objects that have pending data definition changes........................ 189

    Altering stored procedures................................................................................................................ 191Altering user-defined functions.........................................................................................................193Altering implicitly created XML objects.............................................................................................194Changing the high-level qualifier for Db2 data sets..........................................................................195

    Defining a new integrated catalog alias....................................................................................... 195Changing the qualifier for system data sets................................................................................ 195Changing qualifiers for other databases and user data sets.......................................................199

    Tools for moving Db2 data.................................................................................................................203Moving Db2 data...........................................................................................................................205Moving a Db2 data set.................................................................................................................. 206

    v

  • Part 2. Operation and recovery...........................................................................209

    Chapter 4. Controlling Db2 operations by using commands..................................................................331Issuing commands from the z/OS console........................................................................................333Issuing commands from TSO terminals............................................................................................ 333Issuing commands from CICS terminals...........................................................................................335Issuing commands from IMS terminals............................................................................................ 335Issuing commands from application programs................................................................................ 336Destinations for command output messages................................................................................... 337Unsolicited Db2 messages................................................................................................................ 337

    Chapter 5. Starting and stopping Db2.....................................................................................................339Starting Db2....................................................................................................................................... 339

    Messages at start..........................................................................................................................339Subsystem parameters at start....................................................................................................340Application defaults module name at start................................................................................. 340Restricting access to data............................................................................................................ 341Ending the wait state at startup................................................................................................... 341Restart options after an abend.....................................................................................................341

    Stopping Db2......................................................................................................................................342

    Chapter 6. Submitting work to Db2.........................................................................................................343Submitting work by using DB2I......................................................................................................... 343Running TSO application programs................................................................................................... 343

    Sources that Db2 checks to find authorization access for an application program................... 344Running IMS application programs................................................................................................... 344Running CICS application programs..................................................................................................345Running batch application programs.................................................................................................345Running application programs using CAF......................................................................................... 346Running application programs using RRSAF.....................................................................................347

    Chapter 7. Scheduling administrative tasks........................................................................................... 349Interacting with the administrative task scheduler.......................................................................... 349

    Adding a task................................................................................................................................ 349Listing scheduled tasks................................................................................................................ 354Listing the status of scheduled tasks...........................................................................................354Updating the schedule for a task................................................................................................. 357Stopping the execution of a task..................................................................................................357Removing a scheduled task..........................................................................................................357Manually starting the administrative task scheduler ................................................................. 358Manually stopping the administrative task scheduler ................................................................358Synchronization between administrative task schedulers in a data sharing environment........359Troubleshooting the administrative task scheduler....................................................................359

    Architecture of the administrative task scheduler............................................................................362The lifecycle of the administrative task scheduler......................................................................363Task lists of the administrative task scheduler........................................................................... 364Architecture of the administrative task scheduler in a data sharing environment.................... 365Accounting information for stored procedure tasks....................................................................366

    Security guidelines for the administrative task scheduler................................................................367User roles in the administrative task scheduler.......................................................................... 367Protection of the interface of the administrative task scheduler................................................368Protection of the resources of the administrative task scheduler.............................................. 368Secure execution of tasks in the administrative task scheduler.................................................369

    Execution of scheduled tasks in the administrative task scheduler................................................ 369Multi-threading in the administrative task scheduler................................................................. 370Scheduling execution of a stored procedure............................................................................... 371

    vi

  • How the administrative task scheduler works with Unicode...................................................... 372Scheduled execution of a JCL job................................................................................................ 372Execution of scheduled tasks in a data sharing environment.....................................................373Time zone considerations for the administrative task scheduler............................................... 373

    Chapter 8. Monitoring and controlling Db2 and its connections............................................................375Controlling Db2 databases and buffer pools.....................................................................................375

    Starting databases........................................................................................................................376Monitoring databases................................................................................................................... 378Obtaining information about application programs.................................................................... 380Obtaining information about and handling pages in error...........................................................381Making objects unavailable.......................................................................................................... 384Altering buffer pools.....................................................................................................................386Monitoring buffer pools................................................................................................................ 386

    Controlling user-defined functions....................................................................................................387Starting user-defined functions................................................................................................... 388Monitoring user-defined functions...............................................................................................388Stopping user-defined functions..................................................................................................389

    Controlling Db2 utilities..................................................................................................................... 390Starting online utilities................................................................................................................. 390Monitoring and changing online utilities...................................................................................... 390Controlling Db2 stand-alone utilities........................................................................................... 391

    Controlling the IRLM.......................................................................................................................... 392z/OS commands that operate on IRLM........................................................................................393Starting the IRLM..........................................................................................................................394Stopping the IRLM........................................................................................................................ 394

    Monitoring threads.............................................................................................................................395Monitoring threads with DISPLAY THREAD commands..............................................................396Monitoring threads with profile tables.........................................................................................403Monitoring idle threads with profile tables..................................................................................406

    Controlling connections..................................................................................................................... 409Controlling TSO connections........................................................................................................409Controlling CICS connections.......................................................................................................412Controlling IMS connections........................................................................................................ 417Controlling RRS connections........................................................................................................426Controlling connections to remote systems................................................................................ 430

    Monitoring and controlling Db2 with profile tables...........................................................................452Starting and stopping profiles...................................................................................................... 454Modifying existing profiles............................................................................................................455How Db2 applies multiple matching profiles for threads and connections................................455Examples for profiles that monitor and control threads and connections................................. 459

    Controlling traces...............................................................................................................................462Diagnostic traces for attachment facilities.................................................................................. 462Controlling the Db2 trace............................................................................................................. 463Diagnostic trace for the IRLM.......................................................................................................463

    Setting the priority of stored procedures.......................................................................................... 464Setting special registers with profile tables...................................................................................... 464

    Chapter 9. Managing the log and the bootstrap data set....................................................................... 469How database changes are made......................................................................................................469

    Units of recovery and points of consistency................................................................................ 469How Db2 rolls back work..............................................................................................................470How the initial Db2 logging environment is established............................................................. 471How Db2 creates log records....................................................................................................... 471How Db2 writes the active log......................................................................................................471How Db2 writes (offloads) the archive log...................................................................................472

    How Db2 retrieves log records.......................................................................................................... 476Managing the log................................................................................................................................ 476

    vii

  • Quiescing activity before offloading.............................................................................................477Archiving the log........................................................................................................................... 478Adding an active log data set to the active log inventory with the SET LOG command............. 479Dynamically changing the checkpoint frequency........................................................................480Setting limits for archive log tape units....................................................................................... 480Monitoring the system checkpoint...............................................................................................481Displaying log information............................................................................................................481

    What to do before RBA or LRSN limits are reached.......................................................................... 481Converting the BSDS to the 10-byte RBA and LRSN................................................................... 483Converting page sets to the 10-byte RBA or LRSN format..........................................................485Resetting the log RBA value in a data sharing environment (6-byte format)............................. 486Resetting the log RBA value in a non-data sharing environment (6-byte format)..................... 488

    Canceling and restarting an offload...................................................................................................490Displaying the status of an offload.................................................................................................... 490Discarding archive log records...........................................................................................................490Locating archive log data sets........................................................................................................... 491Management of the bootstrap data set............................................................................................. 493

    Restoring dual-BSDS mode..........................................................................................................494BSDS copies with archive log data sets....................................................................................... 494Recommendations for changing the BSDS log inventory............................................................495

    Chapter 10. Restarting Db2 after termination........................................................................................ 497Methods of restarting.........................................................................................................................497

    Types of termination.....................................................................................................................497Normal restart and recovery........................................................................................................ 498Automatic restart..........................................................................................................................502Restart in a data sharing environment.........................................................................................503Restart implications for table spaces that are not logged.......................................................... 503Conditional restart........................................................................................................................503

    Terminating Db2 normally................................................................................................................. 504Restarting automatically....................................................................................................................504Deferring restart processing.............................................................................................................. 505Performing conditional restart...........................................................................................................506

    Conditional restart with system-level backups........................................................................... 506Options for recovery operations after conditional restart...........................................................507Conditional restart records.......................................................................................................... 507

    Resolving postponed units of recovery............................................................................................. 507Recovering from an error during RECOVER POSTPONED processing.............................................. 509

    Chapter 11. Maintaining consistency across multiple systems............................................................. 511Multiple system consistency............................................................................................................. 511

    Two-phase commit process.........................................................................................................511Commit coordinator and multiple participants............................................................................513Illustration of multi-site update...................................................................................................514Termination for multiple systems................................................................................................ 515Consistency after termination or failure...................................................................................... 515Normal restart and recovery for multiple systems......................................................................516Multiple-system restart with conditions......................................................................................517Heuristic decisions about whether to commit or abort an indoubt thread.................................518

    Resolving indoubt units of recovery.................................................................................................. 518Resolution of IMS indoubt units of recovery............................................................................... 518Resolution of CICS indoubt units of recovery..............................................................................519Resolution of RRS indoubt units of recovery............................................................................... 520Resolving WebSphere Application Server indoubt units of recovery..........................................520Resolving remote DBMS indoubt units of recovery..................................................................... 522Determining the coordinator's commit or abort decision........................................................... 523Recovering indoubt threads......................................................................................................... 523Resetting the status of an indoubt thread................................................................................... 524

    viii

  • Resolving an indoubt unit of recovery during Db2 restart...........................................................524

    Chapter 12. Backing up and recovering your data................................................................................. 527Plans for recovery of distributed data............................................................................................... 528Plans for recovering the Db2 tables and indexes used to support Db2 query acceleration............528Plans for extended recovery facility toleration................................................................................. 528Plans for recovery of indexes.............................................................................................................529Actions to take when you back up data.............................................................................................529Actions to avoid when you back up data........................................................................................... 530Preparation for recovery: a scenario................................................................................................. 531Events that occur during recovery..................................................................................................... 532

    Complete recovery cycles............................................................................................................ 533A recovery cycle example when using image copies.................................................................. 534How DFSMShsm affects your recovery environment.................................................................. 534

    Tips for maximizing data availability during backup and recovery...................................................535Where to find recovery information...................................................................................................538How to report recovery information.................................................................................................. 539Discarding SYSCOPY and SYSLGRNX records...................................................................................540Preparations for disaster recovery.................................................................................................... 541

    System-wide points of consistency............................................................................................. 542Recommendations for more effective recovery from inconsistency................................................542

    Actions to take to aid in successful recovery of inconsistent data............................................. 542Actions to avoid in recovery of inconsistent data........................................................................544

    How to recover multiple objects in parallel.......................................................................................545Recovery of page sets and data sets................................................................................................. 545

    Recovery of the work file database..............................................................................................547Page set and data set copies........................................................................................................547System-level backups for object-level recoveries...................................................................... 550

    Recovery of data to a prior point in time........................................................................................... 551Plans for point-in-time recovery.................................................................................................. 552Point-in-time recovery with system-level backups.....................................................................552Point-in-time recovery using the RECOVER utility...................................................................... 554Implications of moving data sets after a system-level backup.................................................. 563Recovery of table spaces..............................................................................................................564Recovery of indexes......................................................................................................................566Recovery of FlashCopy image copies...........................................................................................567Preparing to recover to a prior point of consistency................................................................... 568

    Preparing to recover an entire Db2 subsystem to a prior point in time using image copies orobject-level backups.....................................................................................................................570

    Creating essential disaster recovery elements................................................................................. 571Resolving problems with a user-defined work file data set..............................................................572Resolving problems with Db2-managed work file data sets............................................................ 573Recovering error ranges for a work file table space..........................................................................573

    Recovery of error ranges for a work file table space................................................................... 574Recovering after a conditional restart of Db2................................................................................... 574

    Recovery of the catalog and directory......................................................................................... 574Regenerating missing identity column values...................................................................................575

    Recovery of tables that contain identity columns....................................................................... 575Recovering a table space and all of its indexes................................................................................ 576

    Recovery implications for objects that are not logged................................................................ 576Removing various pending states from LOB and XML table spaces.................................................580Restoring data by using DSN1COPY.................................................................................................. 580Backing up and restoring data with non-Db2 dump and restore..................................................... 580Recovering accidentally dropped objects......................................................................................... 581

    How to avoid accidentally dropping objects................................................................................581Recovering an accidentally dropped table.................................................................................. 581Recovering an accidentally dropped table space........................................................................583

    Recovering a Db2 system to a given point in time using the RESTORE SYSTEM utility...................587

    ix

  • Recovering by using Db2 restart recovery........................................................................................ 588Recovering by using FlashCopy volume backups............................................................................. 588Making catalog definitions consistent with your data after recovery to a prior point in time..........589

    Recovery of catalog and directory tables.....................................................................................591Performing remote site recovery from a disaster at a local site.......................................................591

    Recovering with the BACKUP SYSTEM and RESTORE SYSTEM utilities..................................... 592Recovering without using the BACKUP SYSTEM utility............................................................... 592

    Backup and recovery involving clone tables..................................................................................... 593Recovery of temporal tables with system-period data versioning...................................................593Data restore of an entire system....................................................................................................... 593

    Recovering from different Db2 for z/OS problems................................................................................. 209Recovering from IRLM failure............................................................................................................ 209Recovering from z/OS or power failure............................................................................................. 209Recovering from disk failure.............................................................................................................. 210Recovering from application errors................................................................................................... 212

    Backing out incorrect application changes (with a quiesce point)............................................. 212Backing out incorrect application changes (without a quiesce point)........................................ 213

    Recovering from IMS-related failures .............................................................................................. 214Recovering from IMS control region failure ................................................................................ 214Recovering from IMS indoubt units of recovery.......................................................................... 215Recovering from IMS application failure......................................................................................217Recovering from a Db2 failure in an IMS environment................................................................217

    Recovering from CICS-related failure ...............................................................................................218Recovering from CICS application failures.................................................................................. 218Recovering Db2 when CICS is not operational ........................................................................... 218Recovering Db2 when the CICS attachment facility cannot connect to Db2 .............................219Recovering CICS indoubt units of recovery................................................................................. 220Recovering from CICS attachment facility failure ...................................................................... 222

    Recovering from a QMF query failure................................................................................................ 223Recovering from subsystem termination ......................................................................................... 224Recovering from temporary resource failure ................................................................................... 225Recovering from active log failures .................................................................................................. 225

    Recovering from being out of space in active logs ..................................................................... 225Recovering from a write I/O error on an active log data set .......................................................226Recovering from a loss of dual active logging .............................................................................227Recovering from I/O errors while reading the active log ............................................................228

    Recovering from archive log failures ................................................................................................ 229Recovering from allocation problems with the archive log ........................................................ 229Recovering from write I/O errors during archive log offload ......................................................230Recovering from read I/O errors on an archive data set during recovery ..................................231Recovering from insufficient disk space for offload processing ................................................ 231

    Recovering from BSDS failures..........................................................................................................232Recovering from an I/O error on the BSDS ................................................................................. 232Recovering from an error that occurs while opening the BSDS ................................................. 233Recovering from unequal timestamps on BSDSs ....................................................................... 233Recovering the BSDS from a backup copy...................................................................................234

    Recovering from BSDS or log failures during restart........................................................................ 236Recovering from failure during log initialization or current status rebuild................................. 239Recovering from a failure during forward log recovery............................................................... 249Recovering from a failure during backward log recovery............................................................254Recovering from a failure during a log RBA read request........................................................... 257Recovering from unresolvable BSDS or log data set problem during restart............................. 258Recovering from a failure resulting from total or excessive loss of log data.............................. 260Resolving inconsistencies resulting from a conditional restart.................................................. 263

    Recovering from Db2 database failure ............................................................................................. 268Recovering a Db2 subsystem to a prior point in time....................................................................... 270Recovering from a down-level page set problem ............................................................................ 271Recovering from a problem with invalid LOBs.................................................................................. 272

    x

  • Recovering from table space I/O errors ........................................................................................... 273Recovering from Db2 catalog or directory I/O errors .......................................................................274Recovering from integrated catalog facility failure .......................................................................... 275

    Recovering VSAM volume data sets that are out of space or destroyed.................................... 275Recovering from out-of-disk-space or extent limit problems ....................................................276

    Recovering from referential constraint violation ..............................................................................280Recovering from distributed data facility failure ..............................................................................281

    Recovering from conversation failure ......................................................................................... 281Recovering from communications database failure....................................................................282Recovering from database access thread failure ....................................................................... 282Recovering from VTAM failure .....................................................................................................283Recovering from VTAM ACB OPEN problems.............................................................................. 283Recovering from TCP/IP failure ...................................................................................................285Recovering from remote logical unit failure ................................................................................285Recovering from an indefinite wait condition.............................................................................. 285Recovering database access threads after security failure ........................................................286

    Performing remote-site disaster recovery ....................................................................................... 287Recovering from a disaster by using system-level backups....................................................... 287Restoring data from image copies and archive logs....................................................................287Recovering from disasters by using a tracker site.......................................................................301Using data mirroring for disaster recovery.................................................................................. 311

    Scenarios for resolving problems with indoubt threads................................................................... 317Scenario: Recovering from communication failure .....................................................................318Scenario: Making a heuristic decision about whether to commit or abort an indoubt thread... 320Scenario: Recovering from an IMS outage that results in an IMS cold start.............................. 321Scenario: Recovering from a Db2 outage at a requester that results in a Db2 cold start.......... 323Scenario: What happens when the wrong Db2 subsystem is cold started.................................326Scenario: Correcting damage from an incorrect heuristic decision about an indoubt thread... 328

    Chapter 13. Reading log records.............................................................................................................595Contents of the log............................................................................................................................. 595

    Unit of recovery log records......................................................................................................... 595Checkpoint log records.................................................................................................................599Database page set control records.............................................................................................. 600Other exception information........................................................................................................ 600

    The physical structure of the log....................................................................................................... 600Physical and logical log records................................................................................................... 600The log record header.................................................................................................................. 601The log control interval definition (LCID).....................................................................................603Log record type codes.................................................................................................................. 606Log record subtype codes............................................................................................................ 607Interpreting data change log records.......................................................................................... 609

    Reading log records with IFI..............................................................................................................610Gathering active log records into a buffer....................................................................................610Reading specific log records (IFCID 0129)..................................................................................611Reading complete log data (IFCID 0306).................................................................................... 612

    Reading complete log data for the GDPS Continuous Availability with zero data loss solution......615Modifying Db2 for the GDPS Continuous Availability with zero data loss solution.................... 615Modifying IFI READS calls for the GDPS Continuous Availability with zero data loss

    environment.............................................................................................................................618Recovering the compression dictionary data set without bringing down a Db2 data sharing

    group........................................................................................................................................618Reading log records with OPEN, GET, and CLOSE............................................................................ 619

    JCL DD statements for Db2 stand-alone log services................................................................. 620Data sharing members that participate in a read........................................................................ 622Registers and return codes.......................................................................................................... 623Stand-alone log OPEN request.....................................................................................................623Stand-alone log GET request....................................................................................................... 625

    xi

  • Stand-alone log CLOSE request................................................................................................... 626Sample application that uses stand-alone log services..............................................................627

    Reading log records with the log capture exit routine...................................................................... 628How RBA and LRSN values are displayed ........................................................................................ 629

    Appendix A. Exit routines...................................................................................631Edit procedures....................................................................................................................................... 631

    Specifying edit procedures................................................................................................................ 632When edit routines are taken.............................................................................................................632Parameter list for edit procedures.....................................................................................................632Incomplete rows and edit routines................................................................................................... 633Expected output for edit routines......................................................................................................634

    Validation routines...................................................................................................................................635Specifying validation routines............................................................................................................635When validation routines are taken...................................................................................................636Parameter list for validation routines................................................................................................ 636Incomplete rows and validation routines..........................................................................................637Expected output for validation routines............................................................................................ 637

    Date and time routines............................................................................................................................ 638Specifying date and time routines..................................................................................................... 638When date and time routines are taken............................................................................................ 639Parameter list for date and time routines......................................................................................... 639Expected output for date and time routines..................................................................................... 640

    Conversion procedures............................................................................................................................641Specifying conversion procedures.....................................................................................................641When conversion procedures are taken............................................................................................642Parameter list for conversion procedures.........................................................................................642Expected output for conversion procedures.....................................................................................643

    Field procedures......................................................................................................................................644Field-definition for field procedures..................................................................................................645Specifying field procedures............................................................................................................... 645When field procedures are taken.......................................................................................................646Control blocks for execution of field procedures.............................................................................. 647Field-definition (function code 8)...................................................................................................... 650Field-encoding (function code 0).......................................................................................................653Field-decoding (function code 4)...................................................................................................... 654

    Log capture routines................................................................................................................................656Specifying log capture routines......................................................................................................... 656When log capture routines are invoked.............................................................................................656Parameter list for log capture routines..............................................................................................657

    Routines for dynamic plan selection in CICS..........................................................................................659General guidelines for writing exit routines............................................................................................659

    Coding rules for exit routines.............................................................................................................659Modifying exit routines.......................................................................................................................660Execution environment for exit routines........................................................................................... 660Registers at invocation for exit routines............................................................................................660Parameter list for exit routines.......................................................................................................... 661

    Row formats for edit and validation routines......................................................................................... 662Column boundaries for edit and validation procedures....................................................................662Null values for edit procedures, field procedures, and validation routines..................................... 662Fixed-length rows for edit and validation routines........................................................................... 663Varying-length rows for edit and validation routines........................................................................663Varying-length rows with nulls for edit and validation routines....................................................... 664EDITPROCs and VALIDPROCs for handling basic and reordered row formats................................ 664Converting basic row format table spaces with edit and validation routines to reordered row

    format............................................................................................................................................664Dates, times, and timestamps for edit and validation routines........................................................666

    xii

  • Parameter list for row format descriptions....................................................................................... 666Db2 codes for numeric data in edit and validation routines.............................................................668

    Appendix B. Stored procedures for administration..............................................671Common SQL API stored procedures..................................................................................................... 671

    Versioning of XML documents........................................................................................................... 672XML input documents........................................................................................................................ 672XML output documents......................................................................................................................674XML message documents.................................................................................................................. 675

    Troubleshooting Db2 stored procedure problems................................................................................. 676

    Information resources for Db2 11 for z/OS and related products......................... 677

    Notices..............................................................................................................679Programming interface information........................................................................................................680Trademarks..............................................................................................................................................681Terms and conditions for product documentation.................................................................................681Privacy policy considerations..................................................................................................................681

    Glossary............................................................................................................ 683

    Index................................................................................................................ 685

    xiii

  • xiv

  • About this information

    This information provides guidance information that you can use to perform a variety of administrativetasks with Db2 for z/OS (Db2).

    Throughout this information, "Db2" means "Db2 11 for z/OS". References to other Db2 products usecomplete names or specific abbreviations.

    Important: To find the most up to date content for Db2 11 for z/OS, always use IBM® Knowledge Centeror download the latest PDF file from PDF format manuals for Db2 11 for z/OS (Db2 Home).

    This information assumes that Db2 11 is running in new-function mode, and that your application isrunning with the application compatibility value of 'V11R1'.

    Availability of new function in Db2 11

    The behavior of data definition statements such as CREATE, ALTER, and DROP, which embed datamanipulation SQL statements that contain new capabilities, depends on the application compatibilityvalue that is in effect for the application. An application compatibility value of 'V11R1' must be ineffect for applications to use new capability in embedded statements such as SELECT, INSERT,UPDATE, DELETE, MERGE, CALL, and SET assignment-statement. Otherwise, an applicationcompatibility value of 'V10R1' can be used for data definition statements.

    Generally, new SQL capabilities, including changes to existing language elements, functions, datamanipulation statements, and limits, are available only in new-function mode with applications set toan application compatibility value of 'V11R1'.

    Optimization and virtual storage enhancements are available in conversion mode unless statedotherwise.

    SQL statements can continue to run with the same expected behavior as in DB2® 10 new-functionmode with an application compatibility value of 'V10R1'.

    Who should read this informationThis information is primarily intended for system and database administrators. It assumes that the user isfamiliar with:

    • The basic concepts and facilities of Db2• Time Sharing Option (TSO) and Interactive System Productivity Facility (ISPF)• The basic concepts of Structured Query Language (SQL)• The basic concepts of Customer Information Control System (CICS®)• The basic concepts of Information Management System (IMS)• How to define and allocate z/OS data sets using job control language (JCL).

    Certain tasks require additional skills, such as knowledge of Transmission Control Protocol/InternetProtocol (TCP/IP) or Virtual Telecommunications Access Method (VTAM®) to set up communicationbetween Db2 subsystems, or knowledge of the IBM System Modification Program (SMP/E) to install IBMlicensed programs.

    Db2 Utilities Suite for z/OSImportant: In Db2 11, the Db2 Utilities Suite for z/OS is available as an optional product. You mustseparately order and purchase a license to such utilities, and discussion of those utility functions in thispublication is not intended to otherwise imply that you have a license to them.

    Db2 11 utilities can use the DFSORT program regardless of whether you purchased a license for DFSORTon your system. For more information, see the following informational APARs:

    © Copyright IBM Corp. 1982, 2020 xv

    https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/home/src/tpc/db2z_11_prodhome.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/home/src/tpc/db2z_pdfmanuals.html

  • • II14047• II14213• II13495

    Db2 utilities can use IBM Db2 Sort for z/OS (5655-W42) as an alternative to DFSORT for utility SORT andMERGE functions. Use of Db2 Sort for z/OS requires the purchase of a Db2 Sort for z/OS license. For moreinformation about Db2 Sort for z/OS, see Db2 Sort for z/OS.

    Related conceptsDb2 utilities packaging (Db2 Utilities)

    Terminology and citationsWhen referring to a Db2 product other than Db2 for z/OS, this information uses the product's full name toavoid ambiguity.

    About the Db2 brand change: IBM has re-branded DB2 to Db2, and Db2 for z/OS is now the name of theoffering previously know as "DB2 for z/OS". During and after implementation of this change, you mightsometimes still see references to the original names, such as "DB2 for z/OS" and "DB2", in different IBMweb pages and documents. However, assume that these refer to the same "Db2 for z/OS" product whenthe PID, Entitlement Entity, version, modification, and release information match. For more information,see Revised naming for IBM Db2 family products on IBM z/OS platform.

    The following terms are used as indicated:

    Db2Represents either the Db2 licensed program or a particular Db2 subsystem.

    Tivoli® OMEGAMON® XE for Db2 Performance Expert on z/OSRefers to any of the following products:

    • IBM Tivoli OMEGAMON XE for Db2 Performance Expert on z/OS• IBM Db2 Performance Monitor on z/OS• IBM Db2 Performance Expert for Multiplatforms and Workgroups• IBM Db2 Buffer Pool Analyzer for z/OS

    C, C++, and C languageRepresent the C or C++ programming language.

    CICSRepresents CICS Transaction Server for z/OS.

    IMSRepresents the IMS Database Manager or IMS Transaction Manager.

    MVS™Represents the MVS element of the z/OS operating system, which is equivalent to the Base ControlProgram (BCP) component of the z/OS operating system.

    RACF®Represents the functions that are provided by the RACF component of the z/OS Security Server.

    Accessibility features for Db2 11 for z/OSAccessibility features help a user who has a physical disability, such as restricted mobility or limitedvision, to use information technology products successfully.

    Accessibility features

    The following list includes the major accessibility features in z/OS products, including Db2 11 for z/OS.These features support:

    • Keyboard-only operation.

    xvi About this information

    http://www.ibm.com/software/data/db2imstools/db2tools/db2-sort/https://www.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/ugref/src/tpc/db2z_utlpackaging.htmlhttps://www-01.ibm.com/common/ssi/ShowDoc.wss?docURL=/common/ssi/rep_ca/7/899/ENUSLP18-0047/index.html

  • • Interfaces that are commonly used by screen readers and screen magnifiers.• Customization of display attributes such as color, contrast, and font size

    Tip: The IBM Knowledge Center (which includes information for Db2 for z/OS) and its related publicationsare accessibility-enabled for the IBM Home Page Reader. You can operate all features using the keyboardinstead of the mouse.

    Keyboard navigation

    For information about navigating the Db2 for z/OS ISPF panels using TSO/E or ISPF, refer to the z/OSTSO/E Primer, the z/OS TSO/E User's Guide, and the z/OS ISPF User's Guide. These guides describe how tonavigate each interface, including the use of keyboard shortcuts or function keys (PF keys). Each guideincludes the default settings for the PF keys and explains how to modify their functions.

    Related accessibility information

    IBM and accessibility

    See the IBM Accessibility Center at http://www.ibm.com/able for more information about the commitmentthat IBM has to accessibility.

    How to send your commentsYour feedback helps IBM to provide quality information. Please send any comments that you have aboutthis book or other Db2 for z/OS documentation.

    Send your comments by email to [email protected] and include the name of the product, the versionnumber of the product, and the number of the book. If you are commenting on specific text, please listthe location of the text (for example, a chapter and section title or a help topic title).

    How to read syntax diagramsCertain conventions apply to the syntax diagrams that are used in IBM documentation.

    Apply the following rules when reading the syntax diagrams that are used in Db2 for z/OS documentation:

    • Read the syntax diagrams from left to right, from top to bottom, following the path of the line.

    The ►►─── symbol indicates the beginning of a statement.The ───► symbol indicates that the statement syntax is continued on the next line.The ►─── symbol indicates that a statement is continued from the previous line.The ───►◄ symbol indicates the end of a statement.

    • Required items appear on the horizontal line (the main path).required_item

    • Optional items appear below the main path.required_item

    optional_item

    If an optional item appears above the main path, that item has no effect on the execution of thestatement and is used only for readability.

    required_item

    optional_item

    • If you can choose from two or more items, they appear vertically, in a stack.

    About this information xvii

    http://www.ibm.com/ablemailto:[email protected]

  • If you must choose one of the items, one item of the stack appears on the main path.

    required_item required_choice1

    required_choice2

    If choosing one of the items is optional, the entire stack appears below the main path.

    required_item

    optional_choice1

    optional_choice2

    If one of the items is the default, it appears above the main path and the remaining choices are shownbelow.

    required_item

    default_choice

    optional_choice

    optional_choice

    • An arrow returning to the left, above the main line, indicates an item that can be repeated.

    required_item repeatable_item

    If the repeat arrow contains a comma, you must separate repeated items with a comma.

    required_item

    ,

    repeatable_item

    A repeat arrow above a stack indicates that you can repeat the items in the stack.• Sometimes a diagram must be split into fragments. The syntax fragment is shown separately from the

    main syntax diagram, but the contents of the fragment should be read as if they are on the main path ofthe diagram.

    required_item fragment-name

    fragment-namerequired_item

    optional_name

    • With the exception of XPath keywords, keywords appear in uppercase (for example, FROM). Keywordsmust be spelled exactly as shown. XPath keywords are defined as lowercase names, and must bespelled exactly as shown. Variables appear in all lowercase letters (for example, column-name). Theyrepresent user-supplied names or values.

    • If punctuation marks, parentheses, arithmetic operators, or other such symbols are shown, you mustenter them as part of the syntax.

    Related conceptsCommands in Db2 (Db2 Commands)Db2 online utilities (Db2 Utilities)Db2 stand-alone utilities (Db2 Utilities)

    xviii Db2 11 for z/OS: Administration Guide

    https://www.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/comref/src/tpc/db2z_aboutcommands.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/ugref/src/tpc/db2z_onlineutilities.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/ugref/src/tpc/db2z_standaloneutilities.html

  • Part 1. Designing and implementing Db2 databases

    © Copyright IBM Corp. 1982, 2020 1

  • 2 Db2 11 for z/OS: Administration Guide

  • Chapter 1. Database objects and relationshipsThe general tasks that are necessary to design a database are logical data modeling and physical datamodeling.

    In logical data modeling, you design a model of the data without paying attention to specific functions andcapabilities of the DBMS that will store the data. In fact, you could even build a logical data model withoutknowing which DBMS you will use.

    Physical data modeling begins when you move closer to a physical implementation. The primary purposeof the physical design stage is to optimize performance while ensuring the integrity of the data.

    Logical database design with the entity-relationship modelBefore you implement a database, you should plan or design the database so that it satisfies allrequirements.

    Designing and implementing a successful database, one that satisfies the needs of an organization,requires a logical data model. Logical data modeling is the process of documenting the comprehensivebusiness information requirements in an accurate and consistent format. Analysts who do data modelingdefine the data items and the business rules that affect those data items. The process of data modelingacknowledges that business data is a vital asset that the organization needs to understand and carefullymanage. This section contains information that was adapted from Handbook of Relational DatabaseDesign.

    Consider the following business facts that a manufacturing company needs to represent in its data model:

    • Customers purchase products• Products consist of parts• Suppliers manufacture parts• Warehouses store parts• Transportation vehicles move the parts from suppliers to warehouses and then to manufacturers

    These are all business facts that a manufacturing company's logical data model needs to include. Manypeople inside and outside the company rely on information that is based on these facts. Many reportsinclude data about these facts.

    Any business, not just manufacturing companies, can benefit from the task of data modeling. Databasesystems that supply information to decision makers, customers, suppliers, and others are moresuccessful if their foundation is a sound data model.

    Modeling your dataData analysts can perform the task of data modeling in a variety of ways.

    Procedure

    To model data:1. Build critical user views.

    a) Carefully examining a single business activity or function.b) Develop a user view, which is the model or representation of critical information that the business

    activity r