724
Db2 12 for z/OS Administration Guide IBM SC27-8844-02

Db2 12 for z/OS: Administration Guide - IBM€¦ · This edition applies to Db2® 12 for z/OS® (product number 5650-DB2), Db2 12 for z/OS Value Unit Edition (product number 5770-AF3),

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

  • Db2 12 for z/OS

    Administration Guide

    IBM

    SC27-8844-02

  • 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 12 for z/OS ().

    2020-04-08 edition

    This edition applies to Db2® 12 for z/OS® (product number 5650-DB2), Db2 12 for z/OS Value Unit Edition (productnumber 5770-AF3), 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_12.0.0/home/src/tpc/db2z_pdfmanuals.html

  • Contents

    About this information......................................................................................... xvWho should read this information.............................................................................................................xviDb2 Utilities Suite for z/OS........................................................................................................................xviTerminology and citations......................................................................................................................... xviAccessibility features for Db2 12 for z/OS............................................................................................... xviiHow to send your comments....................................................................................................................xviiHow to read syntax diagrams.................................................................................................................. xviii

    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....................................................................38

    Implementing Db2 table spaces..........................................................................................................39Table 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.................................................................................................................... 56Creating base tables....................................................................................................................... 56

    iii

  • Guidelines for table names.............................................................................................................57Creating temporary tables..............................................................................................................57Creating temporal tables................................................................................................................ 62Creating materialized query tables................................................................................................ 74Creating tables partitioned by data value ranges.......................................................................... 75Nullable partitioning columns........................................................................................................ 76Creating a clone table .................................................................................................................... 77Creating an archive table................................................................................................................79

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

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

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

    Loading data into Db2 tables............................................................................................................... 87Loading data with the LOAD utility................................................................................................. 87Loading data by using the INSERT statement............................................................................... 89Loading data with DRDA fast load (zLoad)..................................................................................... 92Loading data from DL/I...................................................................................................................95

    Implementing Db2 stored procedures................................................................................................ 95Creating stored procedures............................................................................................................96Dropping stored procedures...........................................................................................................97

    Implementing Db2 user-defined functions......................................................................................... 97Creating user-defined functions.....................................................................................................97Deleting user-defined functions.....................................................................................................99

    Obfuscating source code of SQL procedures, SQL functions, and triggers........................................ 99Estimating disk storage for user data................................................................................................101

    General approach to estimating storage..................................................................................... 101Calculating the space required for a table .................................................................................. 103Calculating the space required for an index................................................................................ 106

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

    Retrieving catalog information about Db2 storage groups......................................................... 113Retrieving catalog information about a table.............................................................................. 114Retrieving catalog information about partition order..................................................................114Retrieving catalog information about aliases.............................................................................. 115Retrieving catalog information about columns............................................................................115Retrieving catalog information about indexes.............................................................................116Retrieving catalog information about views................................................................................ 117Retrieving catalog information about authorizations.................................................................. 117Retrieving catalog information about primary keys.................................................................... 118Retrieving catalog information about foreign keys......................................................................118Retrieving catalog information about check pending..................................................................119Retrieving catalog information about check constraints.............................................................119Retrieving catalog information about LOBs................................................................................. 120Retrieving catalog information about user-defined functions and stored procedures.............. 121Retrieving catalog information about triggers............................................................................. 121Retrieving catalog information about sequences........................................................................122Adding and retrieving comments................................................................................................. 122Verifying the accuracy of the database definition....................................................................... 123

    iv

  • Altering Db2 databases......................................................................................................................123Altering Db2 storage groups.............................................................................................................. 123

    Letting SMS manage your Db2 storage groups............................................................................124Adding or removing volumes from a Db2 storage group.............................................................125Migrating existing data sets to a solid-state drive.......................................................................126

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

    Altering Db2 tables............................................................................................................................ 138Adding a column to a table...........................................................................................................139Specifying a default value when altering a column..................................................................... 141Altering the data type of a column...............................................................................................142Altering a table for referential integrity....................................................................................... 151Adding or dropping table check constraints................................................................................154Adding partitions.......................................................................................................................... 155Altering partitions......................................................................................................................... 160Adding XML columns.................................................................................................................... 168Altering the size of your hash spaces ..........................................................................................169Adding a system period and system-period data versioning to an existing table......................170Adding an application period to a table....................................................................................... 172Manipulating data in a system-period temporal table................................................................ 172Altering materialized query tables...............................................................................................173Altering the assignment of a validation routine...........................................................................175Altering a table to capture changed data.....................................................................................175Changing an edit procedure or a field procedure........................................................................ 176Altering the subtype of a string column.......................................................................................176Altering the attributes of an identity column...............................................................................177Changing data types by dropping and re-creating the table....................................................... 177Moving a table to a table space of a different page size..............................................................181

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

    Altering Db2 indexes..........................................................................................................................183Alternative method for altering an index..................................................................................... 184Adding columns to an index......................................................................................................... 184Altering how varying-length index columns are stored...............................................................186Altering the clustering of an index............................................................................................... 187Dropping and redefining a Db2 index...........................................................................................188Reorganizing indexes....................................................................................................................189

    Pending data definition changes....................................................................................................... 190Materializing pending definition changes.................................................................................... 193Restrictions for changes to objects that have pending data definition changes........................ 197Pending column alterations......................................................................................................... 200

    Altering stored procedures................................................................................................................ 202Altering user-defined functions.........................................................................................................203Altering implicitly created XML objects.............................................................................................204Changing the high-level qualifier for Db2 data sets..........................................................................205

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

    Tools for moving Db2 data.................................................................................................................213Moving Db2 data...........................................................................................................................215

    v

  • Moving a Db2 data set.................................................................................................................. 216

    Part 2. Operation and recovery...........................................................................219

    Chapter 4. Controlling Db2 operations by using commands..................................................................339Issuing commands from the z/OS console........................................................................................341Issuing commands from TSO terminals............................................................................................ 341Issuing commands from CICS terminals...........................................................................................343Issuing commands from IMS terminals............................................................................................ 343Issuing commands from application programs................................................................................ 344Destinations for command output messages................................................................................... 345Unsolicited Db2 messages................................................................................................................ 345

    Chapter 5. Starting and stopping Db2.....................................................................................................347Starting Db2....................................................................................................................................... 347

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

    Stopping Db2......................................................................................................................................350

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

    Sources that Db2 checks to find authorization access for an application program................... 352Running IMS application programs................................................................................................... 352Running CICS application programs..................................................................................................353Running batch application programs.................................................................................................354Running application programs using CAF......................................................................................... 355Running application programs using RRSAF.....................................................................................355

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

    Adding a task................................................................................................................................ 357Listing scheduled tasks................................................................................................................ 362Listing the status of scheduled tasks...........................................................................................363Updating the schedule for a task................................................................................................. 365Stopping the execution of a task..................................................................................................365Removing a scheduled task..........................................................................................................366Manually starting the administrative task scheduler ................................................................. 366Manually stopping the administrative task scheduler ................................................................367Synchronization between administrative task schedulers in a data sharing environment........367Troubleshooting the administrative task scheduler....................................................................368

    Architecture of the administrative task scheduler............................................................................370The lifecycle of the administrative task scheduler......................................................................371Task lists of the administrative task scheduler........................................................................... 373Architecture of the administrative task scheduler in a data sharing environment.................... 373Accounting information for stored procedure tasks....................................................................374

    Security guidelines for the administrative task scheduler................................................................375User roles in the administrative task scheduler.......................................................................... 375Protection of the interface of the administrative task scheduler................................................376Protection of the resources of the administrative task scheduler.............................................. 376Secure execution of tasks in the administrative task scheduler.................................................377

    Execution of scheduled tasks in the administrative task scheduler................................................ 377Multi-threading in the administrative task scheduler................................................................. 378

    vi

  • Scheduling execution of a stored procedure............................................................................... 379How the administrative task scheduler works with Unicode...................................................... 380Scheduled execution of a JCL job................................................................................................ 380Execution of scheduled tasks in a data sharing environment.....................................................381Time zone considerations for the administrative task scheduler............................................... 381

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

    Starting databases........................................................................................................................384Monitoring databases................................................................................................................... 386Obtaining information about application programs.................................................................... 388Obtaining information about and handling pages in error...........................................................390Making objects unavailable.......................................................................................................... 392Altering buffer pools.....................................................................................................................394Monitoring buffer pools................................................................................................................ 394

    Controlling user-defined functions....................................................................................................395Starting user-defined functions................................................................................................... 396Monitoring user-defined functions...............................................................................................397Stopping user-defined functions..................................................................................................397

    Controlling Db2 utilities..................................................................................................................... 398Starting online utilities................................................................................................................. 398Monitoring and changing online utilities...................................................................................... 398Controlling Db2 stand-alone utilities........................................................................................... 399

    Controlling the IRLM.......................................................................................................................... 400z/OS commands that operate on IRLM........................................................................................401Starting the IRLM..........................................................................................................................402Stopping the IRLM........................................................................................................................ 402

    Monitoring threads.............................................................................................................................403Types of threads........................................................................................................................... 404Output of the DISPLAY THREAD command.................................................................................404Displaying information about threads..........................................................................................405Monitoring all DBMSs in a transaction......................................................................................... 409

    Controlling connections..................................................................................................................... 411Controlling TSO connections........................................................................................................411Controlling CICS connections.......................................................................................................414Controlling IMS connections........................................................................................................ 419Controlling RRS connections........................................................................................................428Controlling connections to remote systems................................................................................ 432

    Controlling traces...............................................................................................................................452Diagnostic traces for attachment facilities.................................................................................. 452Controlling the Db2 trace............................................................................................................. 453Diagnostic trace for the IRLM.......................................................................................................454

    Setting the priority of stored procedures.......................................................................................... 454Setting special registers with profiles............................................................................................... 455Setting built-in global variables with profiles....................................................................................457

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

    Units of recovery and points of consistency................................................................................ 461How Db2 rolls back work..............................................................................................................462How the initial Db2 logging environment is established............................................................. 463How Db2 creates log records....................................................................................................... 463How Db2 writes the active log......................................................................................................463How Db2 writes (offloads) the archive log...................................................................................464

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

    Quiescing activity before offloading.............................................................................................469Archiving the log........................................................................................................................... 470

    vii

  • Adding an active log data set to the active log inventory with the SET LOG command............. 471Dynamically changing the checkpoint frequency........................................................................472Setting limits for archive log tape units....................................................................................... 472Monitoring the system checkpoint...............................................................................................473Displaying log information............................................................................................................473

    What to do before RBA or LRSN limits are reached.......................................................................... 474Converting page sets to the 10-byte RBA or LRSN format..........................................................476Resetting the log RBA value in a data sharing environment (6-byte format)............................. 477Resetting the log RBA value in a non-data sharing environment (6-byte format)..................... 478

    Canceling and restarting an offload...................................................................................................480Displaying the status of an offload.................................................................................................... 480Discarding archive log records...........................................................................................................481Locating archive log data sets........................................................................................................... 481Management of the bootstrap data set............................................................................................. 483

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

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

    Types of termination.....................................................................................................................487Normal restart and recovery........................................................................................................ 488Automatic restart..........................................................................................................................492Restart in a data sharing environment.........................................................................................493Restart implications for table spaces that are not logged.......................................................... 493Conditional restart........................................................................................................................493

    Terminating Db2 normally................................................................................................................. 494Restarting automatically....................................................................................................................494Deferring restart processing.............................................................................................................. 495Performing conditional restart...........................................................................................................496

    Conditional restart with system-level backups........................................................................... 496Options for recovery operations after conditional restart...........................................................497Conditional restart records.......................................................................................................... 497

    Resolving postponed units of recovery............................................................................................. 498Recovering from an error during RECOVER POSTPONED processing.............................................. 499

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

    Two-phase commit process.........................................................................................................501Commit coordinator and multiple participants............................................................................503Illustration of multi-site update...................................................................................................504Termination for multiple systems................................................................................................ 505Consistency after termination or failure...................................................................................... 505Normal restart and recovery for multiple systems......................................................................506Multiple-system restart with conditions......................................................................................507Heuristic decisions about whether to commit or abort an indoubt thread.................................508

    Resolving indoubt units of recovery.................................................................................................. 508Resolution of IMS indoubt units of recovery............................................................................... 508Resolution of CICS indoubt units of recovery..............................................................................509Resolution of RRS indoubt units of recovery............................................................................... 510Resolving WebSphere Application Server indoubt units of recovery..........................................510Resolving remote DBMS indoubt units of recovery..................................................................... 512Determining the coordinator's commit or abort decision........................................................... 513Recovering indoubt threads......................................................................................................... 513Resetting the status of an indoubt thread................................................................................... 514Resolving an indoubt unit of recovery during Db2 restart...........................................................514

    Chapter 12. Backing up and recovering your data................................................................................. 517

    viii

  • Plans for recovery of distributed data............................................................................................... 518Plans for recovering the Db2 tables and indexes used to support Db2 query acceleration............518Plans for extended recovery facility toleration................................................................................. 518Plans for recovery of indexes.............................................................................................................519Actions to take when you back up data.............................................................................................519Actions to avoid when you back up data........................................................................................... 520Preparation for recovery: a scenario................................................................................................. 521Events that occur during recovery..................................................................................................... 522

    Complete recovery cycles............................................................................................................ 523A recovery cycle example when using image copies.................................................................. 524How DFSMShsm affects your recovery environment.................................................................. 525

    Tips for maximizing data availability during backup and recovery...................................................525Where to find recovery information...................................................................................................528How to report recovery information.................................................................................................. 529Discarding SYSCOPY and SYSLGRNX records...................................................................................530Preparations for disaster recovery.................................................................................................... 531

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

    Actions to take to aid in successful recovery of inconsistent data............................................. 533Actions to avoid in recovery of inconsistent data........................................................................534

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

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

    Recovery of data to a prior point in time........................................................................................... 541Plans for point-in-time recovery.................................................................................................. 542Point-in-time recovery with system-level backups.....................................................................543Point-in-time recovery using the RECOVER utility...................................................................... 544Implications of moving data sets after a system-level backup.................................................. 553Recovery of table spaces..............................................................................................................554Recovery of indexes......................................................................................................................556Recovery of FlashCopy image copies...........................................................................................557Preparing to recover to a prior point of consistency................................................................... 558

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

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

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

    Recovery of the catalog and directory......................................................................................... 564Regenerating missing identity column values...................................................................................565

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

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

    How to avoid accidentally dropping objects................................................................................571Recovering an accidentally dropped table.................................................................................. 571Recovering an accidentally dropped table space........................................................................574

    Recovering a Db2 system to a given point in time using the RESTORE SYSTEM utility...................577Recovering by using Db2 restart recovery........................................................................................ 578Recovering by using FlashCopy volume backups............................................................................. 579Making catalog definitions consistent with your data after recovery to a prior point in time..........579

    ix

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

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

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

    Recovering from different Db2 for z/OS problems................................................................................. 219Recovering from IRLM failure............................................................................................................ 219Recovering from z/OS or power failure............................................................................................. 220Recovering from disk failure.............................................................................................................. 221Recovering from application errors................................................................................................... 222

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

    Recovering from IMS-related failures .............................................................................................. 224Recovering from IMS control region failure ................................................................................ 224Recovering from IMS indoubt units of recovery.......................................................................... 225Recovering from IMS application failure......................................................................................227Recovering from a Db2 failure in an IMS environment................................................................227

    Recovering from CICS-related failure ...............................................................................................228Recovering from CICS application failures.................................................................................. 228Recovering Db2 when CICS is not operational ........................................................................... 229Recovering Db2 when the CICS attachment facility cannot connect to Db2 .............................230Recovering CICS indoubt units of recovery................................................................................. 230Recovering from CICS attachment facility failure ...................................................................... 233

    Recovering from a QMF query failure................................................................................................ 233Recovering from subsystem termination ......................................................................................... 234Recovering from temporary resource failure ................................................................................... 235Recovering from active log failures .................................................................................................. 235

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

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

    Recovering from BSDS failures..........................................................................................................242Recovering from an I/O error on the BSDS ................................................................................. 242Recovering from an error that occurs while opening the BSDS ................................................. 243Recovering from unequal timestamps on BSDSs ....................................................................... 243Recovering the BSDS from a backup copy...................................................................................244

    Recovering from BSDS or log failures during restart........................................................................ 246Recovering from failure during log initialization or current status rebuild................................. 249Recovering from a failure during forward log recovery............................................................... 259Recovering from a failure during backward log recovery............................................................264Recovering from a failure during a log RBA read request........................................................... 267Recovering from unresolvable BSDS or log data set problem during restart............................. 268Recovering from a failure resulting from total or excessive loss of log data.............................. 270Resolving inconsistencies resulting from a conditional restart.................................................. 273

    Recovering from Db2 database failure ............................................................................................. 278Recovering a Db2 subsystem to a prior point in time....................................................................... 280Recovering from a down-level page set problem ............................................................................ 281Recovering from a problem with invalid LOBs.................................................................................. 282Recovering from table space I/O errors ........................................................................................... 283Recovering from Db2 catalog or directory I/O errors .......................................................................284Recovering from integrated catalog facility failure .......................................................................... 285

    x

  • Recovering VSAM volume data sets that are out of space or destroyed.................................... 285Recovering from out-of-disk-space or extent limit problems ....................................................286

    Recovering from referential constraint violation ..............................................................................290Recovering from distributed data facility failure ..............................................................................291

    Recovering from conversation failure ......................................................................................... 291Recovering from communications database failure....................................................................292Recovering from database access thread failure ....................................................................... 293Recovering from VTAM failure .....................................................................................................293Recovering from VTAM ACB OPEN problems.............................................................................. 294Recovering from TCP/IP failure ...................................................................................................295Recovering from remote logical unit failure ................................................................................295Recovering from an indefinite wait condition.............................................................................. 295Recovering database access threads after security failure ........................................................296

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

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

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

    Unit of recovery log records......................................................................................................... 585Checkpoint log records.................................................................................................................589Database page set control records.............................................................................................. 590Other exception information........................................................................................................ 590

    The physical structure of the log....................................................................................................... 590Physical and logical log records................................................................................................... 590The log record header.................................................................................................................. 591The log control interval definition (LCID).....................................................................................593Log record type codes.................................................................................................................. 596Log record subtype codes............................................................................................................ 597Interpreting data change log records.......................................................................................... 599

    Reading log records with IFI..............................................................................................................600Gathering active log records into a buffer....................................................................................600Reading specific log records (IFCID 0129)..................................................................................601Reading complete log data (IFCID 0306).................................................................................... 602

    Reading complete log data for the GDPS Continuous Availability with zero data loss solution......605Modifying Db2 for the GDPS Continuous Availability with zero data loss solution.................... 606Upgrading a Db2 11 GDPS Continuous Availability with zero data loss environment to a

    Db2 12 environment................................................................................................................608Modifying IFI READS calls for the GDPS Continuous Availability with zero data loss

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

    group........................................................................................................................................610Reading log records with OPEN, GET, and CLOSE............................................................................ 611

    JCL DD statements for Db2 stand-alone log services................................................................. 612Data sharing members that participate in a read........................................................................ 614Registers and return codes.......................................................................................................... 614Stand-alone log OPEN request.....................................................................................................615Stand-alone log GET request....................................................................................................... 616Stand-alone log CLOSE request................................................................................................... 618

    xi

  • Sample application that uses stand-alone log services..............................................................618Reading log records with the log capture exit routine...................................................................... 619How RBA and LRSN values are displayed ........................................................................................ 620

    Appendix A. Exit routines...................................................................................623Edit procedures....................................................................................................................................... 623

    Specifying edit procedures................................................................................................................ 624When edit routines are taken.............................................................................................................624Parameter list for edit procedures.....................................................................................................624Incomplete rows and edit routines................................................................................................... 625Expected output for edit routines......................................................................................................626

    Validation routines...................................................................................................................................627Specifying validation routines............................................................................................................627When validation routines are taken...................................................................................................628Parameter list for validation routines................................................................................................ 628Incomplete rows and validation routines..........................................................................................629Expected output for validation routines............................................................................................ 629

    Date and time routines............................................................................................................................ 630Specifying date and time routines..................................................................................................... 630When date and time routines are taken............................................................................................ 631Parameter list for date and time routines......................................................................................... 631Expected output for date and time routines..................................................................................... 632

    Conversion procedures............................................................................................................................633Specifying conversion procedures.....................................................................................................633When conversion procedures are taken............................................................................................634Parameter list for conversion procedures.........................................................................................634Expected output for conversion procedures.....................................................................................635

    Field procedures......................................................................................................................................636Field-definition for field procedures..................................................................................................637Specifying field procedures............................................................................................................... 637When field procedures are taken.......................................................................................................638Control blocks for execution of field procedures.............................................................................. 639Field-definition (function code 8)...................................................................................................... 642Field-encoding (function code 0).......................................................................................................645Field-decoding (function code 4)...................................................................................................... 646

    Log capture routines................................................................................................................................648Specifying log capture routines......................................................................................................... 648When log capture routines are invoked.............................................................................................648Parameter list for log capture routines..............................................................................................649

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

    Coding rules for exit routines.............................................................................................................651Modifying exit routines.......................................................................................................................652Execution environment for exit routines........................................................................................... 652Registers at invocation for exit routines............................................................................................652Parameter list for exit routines.......................................................................................................... 653

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

    format............................................................................................................................................656Dates, times, and timestamps for edit and validation routines........................................................658Parameter list for row format descriptions....................................................................................... 658

    xii

  • Db2 codes for numeric data in edit and validation routines.............................................................660

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

    Versioning of XML documents........................................................................................................... 664XML input documents........................................................................................................................ 665XML output documents......................................................................................................................666XML message documents.................................................................................................................. 667

    Troubleshooting Db2 stored procedure problems................................................................................. 668

    Information resources for Db2 12 for z/OS and related products......................... 669

    Notices..............................................................................................................671Programming interface information........................................................................................................672Trademarks..............................................................................................................................................673Terms and conditions for product documentation.................................................................................673Privacy policy considerations..................................................................................................................673

    Glossary............................................................................................................ 675

    Index................................................................................................................ 677

    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 12 for z/OS". References to other Db2 products usecomplete names or specific abbreviations.

    Important: To find the most up to date content, always use IBM® Knowledge Center, which is continuallyupdated as soon as changes are ready. PDF manuals are updated only when new editions are published,on an infrequent basis.

    How Db2 function levels are documented:

    Except for the What's new and Installing and migrating Db2 sections, all Db2 12 documentation assumesthat the highest available function level is activated and all applications run at the equivalent applicationcompatibility level. However, changes introduced by function levels are marked by links to the overviewpage for the function level that introduced the changes. For more information, see How Db2 functionlevels are documented (Db2 for z/OS What's New?).

    Overview of Db2 12 new function availabilityThe availability of new function depends on the type of enhancement, the activated function level, andthe application compatibility levels of applications. In the initial Db2 12 release, most new capabilitiesare enabled only after the activation of function level 500 or higher.Virtual storage enhancements

    Virtual storage enhancements become available at the activation of the function level thatintroduces them or higher. Activation of function level 100 introduces all virtual storageenhancements in the initial Db2 12 release. That is, activation of function level 500 introduces novirtual storage enhancements.

    Subsystem parametersNew subsystem parameter settings are in effect only when the function level that introducedthem or a higher function level is activated. Many subsystem parameter changes in the initial Db212 release take effect in function level 500. For more information about subsystem parameterchanges in Db2 12, see Subsystem parameter changes in Db2 12 (Db2 for z/OS What's New?).

    Optimization enhancementsOptimization enhancements become available after the activation of the function level thatintroduces them or higher, and full prepare of the SQL statements. When a full prepare occursdepends on the statement type:

    • For static SQL statements, after bind or rebind of the package• For non-stabilized dynamic SQL statements, immediately, unless the statement is in the

    dynamic statement cache• For stabilized dynamic SQL statements, after invalidation, free, or changed application

    compatibility level

    Activation of function level 100 introduces all optimization enhancements in the initial Db2 12release. That is, function level 500 introduces no optimization enhancements.

    SQL capabilitiesNew SQL capabilities become available after the activation of the function level that introducesthem or higher, for applications that run at the equivalent application compatibility level or higher.New SQL capabilities in the initial Db2 12 release become available in function level 500 forapplications that run at the equivalent application compatibility level or higher. You can continueto run SQL statements compatibly with lower function levels, or previous Db2 releases, includingDb2 11 and DB2® 10. For details, see Application compatibility levels in Db2 (Db2 Applicationprogramming and SQL)

    © Copyright IBM Corp. 1982, 2020 xv

    http://www.ibm.com/support/knowledgecenter/SSEPEK/db2z_prodhome.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/wnew/src/tpc/db2z_aboutflinfo.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/wnew/src/tpc/db2z_aboutflinfo.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/wnew/src/tpc/db2z_12_subsysparmchanges.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/apsg/src/tpc/db2z_applicationcompatibility.htmlhttps://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/apsg/src/tpc/db2z_applicationcompatibility.html

  • 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 this Db2 12, 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 12 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:

    • 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 is rebranding DB2 to Db2. As such, there will be changes to all theDb2 offerings. For example, "DB2 for z/OS" is now referred to as "Db2 for z/OS," beginning with Db2 11.While IBM implements the change across the Db2 family of products, you might see references to theoriginal name "DB2 for z/OS" or "DB2" in different IBM web pages and documents. "DB2 for z/OS" and"Db2 for z/OS" refer to the same product, when the PID, Entitlement Entity, version, modification, andrelease information match. For more information, see Revised naming for IBM Db2 family products.

    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

    xvi About this information

    http://www.ibm.com/software/data/db2imstools/db2tools/db2-sort/https://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/ugref/src/tpc/db2z_utlpackaging.htmlhttps://www-01.ibm.com/common/ssi/ShowDoc.wss?docURL=/common/ssi/rep_ca/3/897/ENUS217-363/index.html

  • • 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 12 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 12 for z/OS.These features support:

    • Keyboard-only operation.• 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.

    About this information xvii

    http://www.ibm.com/able

  • 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.

    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.

    xviii About this information

    mailto:[email protected]

  • 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)

    About this information xix

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

  • xx Db2 12 for z/OS: Administration Guide

  • Part 1. Designing and implementing Db2 databases

    © Copyright IBM Corp. 1982, 2020 1

  • 2 Db2 12 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