Introduction to DB2 for Z/OS
Total Page:16
File Type:pdf, Size:1020Kb
DB2 10 for z/OS Introduction to DB2 for z/OS IBM SC19-2976-15 DB2 10 for z/OS Introduction to DB2 for z/OS IBM SC19-2976-15 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. October 13, 2017 edition This edition applies to DB2 10 for z/OS (product number 5605-DB2), DB2 10 for z/OS Value Unit Edition (product number 5697-P31), and to any subsequent releases until otherwise indicated in new editions. Make sure you are using the 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 caption indicates that the figure has changed. Editorial changes that have no technical significance are not noted. © Copyright IBM Corporation 2001, 2017. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this information ............................. ix Who should read this information ............................ ix DB2 Utilities Suite for z/OS .............................. x Terminology and citations ............................... x Accessibility features for DB2 10 for z/OS ......................... x How to send your comments ............................. xi Chapter 1. What is DB2 for z/OS?......................... 1 Chapter 2. DB2 for z/OS and SQL concepts .................... 3 Submitting SQL statements to DB2 ............................ 3 Static SQL ................................... 5 Embedded dynamic SQL .............................. 5 Deferred embedded SQL .............................. 6 Interactive SQL ................................. 6 SQL Call Level Interface and Open Database Connectivity ................... 7 Java database connectivity and embedded SQL for Java .................... 7 Use of QMF for Workstation ............................. 8 DB2 Database objects overview ............................. 9 DB2 schemas and schema qualifiers ........................... 11 DB2 tables.................................... 12 DB2 keys ................................... 13 Constraints .................................. 14 DB2 columns .................................. 20 DB2 indexes .................................. 34 DB2 views.................................... 35 Aliases ..................................... 37 Triggers .................................... 38 User-defined types ................................. 39 Routines .................................... 40 Functions ................................... 40 Procedures .................................. 40 Sequences .................................... 41 DB2 system objects ................................. 42 DB2 catalog .................................. 42 DB2 directory.................................. 43 Active and archive logs .............................. 44 Bootstrap data set ................................ 45 Buffer pools .................................. 45 Data definition control support database ........................ 46 The resource limit facility.............................. 46 Work file database ................................ 47 Application processes and transactions ......................... 47 Subsystem parameters ............................... 52 Storage structures ................................. 53 DB2 databases ................................. 53 | DB2 table spaces................................. 55 DB2 index spaces ................................ 56 | DB2 hash spaces................................. 56 DB2 storage groups................................ 57 Accessing DB2 data................................. 58 Ways to select data from columns ........................... 59 How a SELECT statement works ........................... 61 SQL functions and expressions ............................ 62 Ways to filter the number of returned rows........................ 70 © Copyright IBM Corp. 2001, 2017 iii Ways to order rows................................ 78 Ways to summarize group values ........................... 81 Ways to merge lists of values ............................ 82 Ways to specify search conditions ........................... 83 Ways to join data from more than one table ....................... 85 Subqueries................................... 92 Ways to access DB2 data that is not in a table ....................... 94 Modifying DB2 data ................................ 94 Insert statements ................................ 95 Update statements ................................ 96 Merge statements ................................ 96 Delete statements ................................ 97 Truncate statements ............................... 97 Defining DB2 objects ................................ 98 Creation of tables ................................ 98 Creation of table spaces .............................. 106 Creation of indexes ............................... 122 Creation of views ................................ 141 Creation of large objects .............................. 144 Creation of databases............................... 145 Creation of relationships with referential constraints .................... 146 Creation of triggers ............................... 150 Creation of user-defined functions .......................... 151 Application processes, concurrency, and recovery ...................... 153 Locking, commit, and rollback............................ 153 Unit of work ................................. 154 Unit of recovery ................................ 154 Rolling back work ................................ 155 Packages and application plans ............................ 156 Character conversion ................................ 157 Character sets and code pages............................ 160 Coded character sets and CCSIDS .......................... 162 Determining the encoding scheme and CCSID of a string .................. 162 Expanding conversions .............................. 166 Contracting conversions .............................. 166 Distributed data ................................. 166 Connections .................................. 167 Distributed unit of work.............................. 168 Remote unit of work ............................... 171 Distributed data ................................. 173 Remote servers ................................. 174 Connectivity in distributed environments ........................ 174 Distributed data access .............................. 175 Support for high availability ............................. 186 DB2 data sharing ................................. 186 Advantages of DB2 data sharing ........................... 187 How DB2 protects data consistency in a data sharing environment ............... 195 How updates are made in a data sharing environment ................... 196 How DB2 writes changed data to disk in a data sharing environment .............. 200 Ways that other tasks are affected by data sharing ..................... 201 Ways that availability is affected by data sharing ..................... 201 pureXML .................................... 202 Chapter 3. Management of DB2 operations.................... 205 Common ways to interact with DB2 for z/OS ....................... 205 The DB2I primary option menu ............................ 207 Commands for controlling DB2 and related facilities ..................... 209 DB2 utilities ................................... 210 Management of data sets .............................. 217 Authorization and security mechanisms for data access .................... 217 How authorization IDs control data access ....................... 218 iv Introduction to DB2 for z/OS How authorization IDs hold privileges and authorities ................... 219 Ways to control access to DB2 subsystems ........................ 220 Ways to control access to data ............................ 222 Ways to control access to DB2 objects through explicit privileges and authorities ........... 223 | Row-level and column-level access control ....................... 225 Use of multilevel security to control access ....................... 225 Use of views to control access ............................ 226 Use of grant and revoke privileges to control access .................... 226 Backup, recovery, and restart ............................. 228 Backup and recovery resources and tools ........................ 230 DB2 restart .................................. 233 Regular backups and data checks........................... 233 Control of database changes and data consistency ..................... 233 Events in the recovery process............................ 236 Optimization of availability during backup and recovery ................... 237 Data encoding basics ................................ 238 Introduction to troubleshooting problems in DB2 for z/OS ................... 241 Chapter 4. DB2 performance management .................... 247 Initial steps for performance management ......................... 247 Performance objectives .............................. 247 Application design for performance .......................... 248 Origin of performance problems ........................... 248 Tools for performance analysis ........................... 249 Ways to move data efficiently through the system ...................... 250 The role of buffer pools in caching data ........................ 250 The effect of data compression on performance .....................