Sunteți pe pagina 1din 238

Business

Intelligence

Data
Centre

Cloud

Mobility

Enterprise Computing Solutions

Student Manual

Direccin General de Formacin


CONSEJERA DE EMPLEO,
TURISMO Y CULTURA

Comunidad de Madrid

UNIN EUROPEA
FONDO SOCIAL EUROPEO
El Fondo Social Europeo invierte en tu futuro

EDUCATION
S

V5.4.0.3

cover

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Front cover

DB2 10 for z/OS


Database Administration
Workshop Part 1
(Course code CV831)

Student Exercises

pr

Ex

cl

ERC 7.0

IBM certified course material

Student Exercises

Trademarks
The reader should recognize that the following terms, which appear in the content of this
training document, are official trademarks of IBM or other companies:
IBM is a registered trademark of International Business Machines Corporation.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
AIX
DRDA
Notes
QMF
z/OS

CICS
IMS
OS/390
RACF
zSeries

DB2
Lotus
Parallel Sysplex
RETAIN
1-2-3

Java and all Java-based trademarks and logos are trademarks of Sun Microsystems, Inc.
in the United States, other countries, or both.

Linux is a registered trademark of Linus Torvalds in the United States, other countries, or
both.
Windows is a trademark of Microsoft Corporation in the United States, other countries, or
both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.

Ex

cl

Other product and service names might be trademarks of IBM or other companies.

pr

October 2011 edition

The information contained in this document has not been submitted to any formal IBM test and is distributed on an as is basis without
any warranty either express or implied. The use of this information or the implementation of any of these techniques is a customer
responsibility and depends on the customers ability to evaluate and integrate them into the customers operational environment. While
each item may have been reviewed by IBM for accuracy in a specific situation, there is no guarantee that the same or similar results will
result elsewhere. Customers attempting to adapt these techniques to their own environments do so at their own risk.

Copyright International Business Machines Corporation 1993, 2011.


This document may not be reproduced in whole or in part without the prior written permission of IBM.
Note to U.S. Government Users Documentation related to restricted rights Use, duplication or disclosure is subject to restrictions
set forth in GSA ADP Schedule Contract with IBM Corp.

V5.4.0.3
Student Exercises

Contents
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Exercises description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Exercise 1. Creating databases and table spaces . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1


Exercise 2. Creating tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table LOCATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table DEPARTMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table EMPLOYEE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table PROJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Tables ON_PROJECT and ACTIVITY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2-1
2-2
2-3
2-4
2-5
2-6
2-7

Exercise 3. Creating and using views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1


Exercise 4. Creating indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1

Exercise 5. Creating referential structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1


Referential structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

Exercise 6. Loading and unloading tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1


Exercise 7. Running RUNSTATS and REORG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1

Exercise 8. Running COPY and RECOVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1


Exercise 9. Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1

cl

Exercise 10. Locking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1

Appendix A. Exercise solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1


Exercise 1: Creating databases and table spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Exercise 2: Creating tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-9
Exercise 3: Creating and using views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-15
Exercise 4: Creating indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-27
Exercise 5: Creating referential structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-37
Exercise 6: Loading and unloading tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-43
Exercise 7: Running RUNSTATS and REORG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-95
Exercise 8: Running COPY and RECOVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-133
Exercise 9: Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-153
Exercise 10: Locking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-161

pr

Ex

TOC

Copyright IBM Corp. 1993, 2011


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Contents

iii

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

iv

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

Trademarks
The reader should recognize that the following terms, which appear in the content of this
training document, are official trademarks of IBM or other companies:
IBM is a registered trademark of International Business Machines Corporation.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

The following are trademarks of International Business Machines Corporation in the United
States, or other countries, or both:
AIX
DRDA
Notes
QMF
z/OS

CICS
IMS
OS/390
RACF
zSeries

DB2
Lotus
Parallel Sysplex
RETAIN
1-2-3

Java and all Java-based trademarks and logos are trademarks of Sun Microsystems, Inc.
in the United States, other countries, or both.

Linux is a registered trademark of Linus Torvalds in the United States, other countries, or
both.
Windows is a trademark of Microsoft Corporation in the United States, other countries, or
both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.

cl

Other product and service names might be trademarks of IBM or other companies.

pr

Ex

TMK

Copyright IBM Corp. 1993, 2011


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Trademarks

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

vi

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

Exercises description
Exercise instructions

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Use the information you have learned in the unit presentation to work
through each exercise. You should also make use of your Student
Notebook and the DB2 manuals.

Note

Your instructor will assign each team a 2-digit team ID, for example, 21, 22, and so on.

Machine lab environment

You have been provided with a partitioned data set named


userid.CV83.CNTL which contains the members supplied for each
exercise. The first two characters of a member name are 'Ln', where 'n'
represents the number of the exercise which uses the member. For
example, Exercise 1 uses a member called L1QUERY1.
The exercise instructions assume that SPUFI will be used to execute
SQL statements.
Optional labs

cl

For those who are experienced and fast, optional lab steps are
provided, which are sometimes a bit more challenging. But the
majority of students should concentrate on performing the normal lab
steps. These are totally sufficient to meet the course objectives. And
these students should be careful not to waste their time with these
optional steps at the expense of the important labs for each unit.

pr

Ex

pref

Copyright IBM Corp. 1993, 2011

Exercises description

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

vii

Student Exercises

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Logging on (1 of 3)

Copyright IBM Corporation 2009

Figure 1. Logging on (1 of 3)

CV8317.0

Notes:

Machine lab environment

cl

Your Personal Communications session will already be configured with the host name
mopedvm2.ilsvpn.ibm.com and you should see the screen above.

We shall be accessing the IBM Training system MOPEDVM2 in Montpellier via the Internet.

Ex

The Aventail client software will enable you to access this system and this software should
already be running on your PC.

pr

On the command line, type the designated z/OS system assigned to your lab, such as
MVSDI11, and press Enter.

viii

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

pref

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Logging on (2 of 3)

Copyright IBM Corporation 2009

Figure 2. Logging on (2 of 3)

CV8317.0

Notes:

Type TSO followed by space, followed by your TSO user ID. Your TSO userid will be
allocated by your instructor and will be something like, for example, TSOUB01.

pr

Ex

cl

Press Enter.

Copyright IBM Corp. 1993, 2011

Exercises description

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

ix

Student Exercises

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Logging on (3 of 3)

Copyright IBM Corporation 2009

Figure 3. Logging on (3 of 3)

CV8317.0

Notes:

Type your password as provided by your instructor.


Check:

cl

Procedure is set to STUDENT

Ex

Account Number is set to 1CV83G26


Command is set to %C26 B CV831

pr

Press Enter.

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

pref

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

ISPF main menu

Copyright IBM Corporation 2009

Figure 4. ISPF main menu

CV8317.0

Notes:

From the ISPF main menu:

Option D will take you to DB2I and SPUFI.

cl

- We shall be using a DB2 subsystem something like, for example, DSNB.

Ex

- Check via DB2I option D that your DB2 name is set to the correct subsystem
identifier.

Option 3.4 will take you to your partitioned data set and the skeleton members.

pr

- Each team is provided with a partitioned data set named userid.CV83.CNTL which
contains the edited skeleton members used in the machine exercises.

Option S is for SDSF.

Copyright IBM Corp. 1993, 2011

Exercises description

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

xi

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

xii

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 1. Creating databases and table spaces


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with creating databases and table spaces.

What you should be able to do

At the end of the exercise, you should be able to create a:


Database

Segmented table space

Partition by growth universal table space

Range partitioned universal table space

pr

Ex

cl

You should also be familiar with the type of information held in the DB2
catalog for databases and table spaces.

Copyright IBM Corp. 1993, 2011

Exercise 1. Creating databases and table spaces

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

1-1

Student Exercises

Exercise instructions
Note

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Throughout these exercises, search for ?? within the PDS members provided for each
problem and replace any ?? with your team ID. Not all members will contain ??.

Creating a database

__ 1. Create a database which has the following attributes:

The name of the database should be WWV83??D, where ?? represents your


team ID.

The name of the default buffer pool to be used for table spaces created within
the database should be BP1.
The name of the default buffer pool to be used for indexes created within the
database should be BP2.

The name of the default storage group to be used to support the DASD space
requirements for table spaces and indexes created within the database should
be WWV83??S, where ?? represents your team ID. This storage group has
already been created for you.

Creating table spaces

When creating the following table spaces, do not specify any other than the requested
options:
__ 2. Create a segmented table space named TSLOCN in your database.

cl

__ 3. Create a partition by growth universal table space named TSDEPT in your


database. TSDEPT should be able to grow up to a maximum of 5 partitions and
have a segment size of 32.

Ex

__ 4. Create a range partitioned universal table space named TSEMPL in your database.
TSEMPL should contain 3 partitions. SEGSIZE, if required, should be 4.

pr

__ 5. Create a segmented table space named TSPROJ in your database. TSPROJ


should have a segment size of 4. Also, specify that you want zero percent of each
page to be left as free space when the table space is loaded or reorganized.

Querying the DB2 catalog tables


The supplied catalog queries refer to a DB2 special register called USER. This special
register contains the value of your TSO userid.

1-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

__ 6. Execute member L1QUERY1 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSDATABASE), explain the meaning of the values held for each column.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 7. Execute member L1QUERY2 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSTABLESPACE), explain the meaning of the values held for each
column.
__ 8. Execute member L1QUERY3 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSTABLEPART), explain the meaning of the values held for each
column.

Optional Labs

__ 9. Queries about volumes:

Which volumes are recorded in the DB2 catalog for the storage group you use?
_________________________
If explicit volumes are defined, can you be sure that the data sets of your table
spaces are stored on these? ________ Why?
__________________________________________________________
__________________________________________________________

__ 10. What are the names of the VSAM clusters of your table space TSEMPL?
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

__ 11. On which volume does the data set of partition 1 of table space TSEMPL reside?
___________

cl

__ 12. Execute the statement provided in member L1CREATE. Why does the CREATE
TABLESPACE statement fail?

Ex

You have two possibilities:

a. You try to answer this question almost on your own, with a few hints only.

b. You work with some more hints.

So, choose the way you prefer:

pr

a. Few hints: Inspect the DB2 address space which issues messages. Or
inspect the syslog. Which reason is given?
__________________________________
Is that really the reason, in other words, is there really a difference to the
previous CREATE TABLESPACE statements, which were successful? What
else could be the reason?

Copyright IBM Corp. 1993, 2011

Exercise 1. Creating databases and table spaces

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

1-3

Student Exercises

b. More hints: First follow the previous section Few hints. Use SDSF and
inspect either the DB2 master address space (ssnnMSTR) or the SYSLOG.
In either case, in order to find the error message(s), look for a portion of the
data set name you intended to define (containing db name and ts name):
WWV83ZZD.TEST??A.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Depending on the environment, the error messages point to security or volume


problems. Ignore these hints: What else, besides security and volumes, is
specified by storage groups, which is used by follow-on table space creations?
___________

Determine from the DB2 catalog the vcat specifications used for TEST??A
__________ and for the other, previously created table spaces: ____________.

Test via ISPF 3.4 whether an alias for these two high-level qualifiers exist at all
(by entering their name in the dsname level field). DB2 can only create a data
set if an alias has been defined for the high-level qualifier or if DB2 is allowed to
update the z/OS master catalog (not recommended, and not allowed on our
system).

pr

Ex

cl

End of exercise

1-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 2. Creating tables


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with creating tables.

What you should be able to do

At the end of the exercise, you should:

Be able to create tables, including the tasks


- To define table check constraints

- To complete the definition of table-controlled table spaces


- To store a table in the correct table space

pr

Ex

cl

Be familiar with the type of information held in the DB2 catalog for
tables

Copyright IBM Corp. 1993, 2011

Exercise 2. Creating tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-1

Student Exercises

Table LOCATION
LOCATION
Null

LOCID
ADDRESS
CITY
POSTAL_CODE

Data Type
(Length)
CHAR(10)
CHAR(30)
CHAR(30)
CHAR(15)

Description

NO
NO
NO
NO

Identifier for location


Street and street number for location
City in which location is situated
Postal code for location (state + zip-code)

COUNTRY

CHAR(30)

NO

Country in which location is situated

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Column Name

Copyright IBM Corporation 2007

Figure 2-1. Table LOCATION

CV8317.0

Notes:

The six tables which you will create in this exercise are described on this and the following
pages. Take time to browse these pages before you start the exercise. The exercise
instructions begin on page 2-8.

pr

Ex

cl

Each row in the LOCATION table describes a business location.

2-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Table DEPARTMENT
DEPARTMENT
Data Type
(Length)
DEPTNO
CHAR(3)
SUPERIOR_DEPTNO CHAR(3)

Null

Description

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Column Name

MGRNO
NAME

NO Department number for department


YES Department number for superior
department (next higher level department)
CHAR(6)
YES Person number of manager for
department
VARCHAR(50) NO Department name

Copyright IBM Corporation 2007

Figure 2-2. Table DEPARTMENT

CV8317.0

Notes:

pr

Ex

cl

Each row in the DEPARTMENT table describes a department.

Copyright IBM Corp. 1993, 2011

Exercise 2. Creating tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-3

Student Exercises

Table EMPLOYEE
EMPLOYEE
Data Type
(Length)
CHAR(6)
CHAR(20)
CHAR(1)
CHAR(1)
DATE
CHAR(4)
DATE
CHAR(20)
SMALLINT
DECIMAL(9,2)
DECIMAL(9,2)
DECIMAL(9,2)
CHAR(3)
CHAR(10)
VARCHAR(50)

Null

Description

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Column Name
EMPNO
FIRST_NAME
MIDDLE_INITIAL
SEX
BIRTHDATE
PHONE
HIRING_DATE
JOB
EDUCATION
SALARY
BONUS
COMMISSION
DEPTNO
LOCID
LAST_NAME

NO
NO
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO

Person number of employee


First name of employee
Middle initial of employee
Sex of employee
Date of birth of employee
Extension for employee
Hiring date for employee
Job title for employee
Education level of employee
Current salary for employee
Current bonus for employee
Current commission for employee
Department for employee
Work location (identifier) for employee
Last name for employee

Copyright IBM Corporation 2007

Figure 2-3. Table EMPLOYEE

CV8317.0

Notes:

pr

Ex

cl

Each row in the EMPLOYEE table describes an employee.

2-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Table PROJECT
PROJECT
Data Type
(Length)
CHAR(6)
CHAR(3)
CHAR(6)
DECIMAL(5,2)
DATE
DATE
VARCHAR(50)

Null

Description

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Column Name
PROJNO
DEPTNO
EMPNO
STAFFING
START_DATE
END_DATE
NAME

NO
NO
NO
YES
YES
YES
NO

Project number for project


Department responsible for project
Employee responsible for project
Estimated mean staffing for project
Projected starting date for project
Projected ending date for project
Project name

Copyright IBM Corporation 2007

Figure 2-4. Table PROJECT

CV8317.0

Notes:

pr

Ex

cl

Each row in the PROJECT table describes a project.

Copyright IBM Corp. 1993, 2011

Exercise 2. Creating tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-5

Student Exercises

Tables ON_PROJECT and ACTIVITY


ON_PROJECT
Data Type
(Length)
CHAR(6)
CHAR(6)

Null

Description

NO
NO

Project number for project


Employee working on project

Data Type
(Length)
CHAR(6)
CHAR(6)
SMALLINT

Null

Description

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Column Name
PROJNO
EMPNO

ACTIVITY

Column Name
PROJNO
EMPNO
SEQNO

Project number for project


Employee performing activity for project
Sequence number for activity
(per project and employee)
SMALLINT
NO Code describing the activity
DECIMAL(5,2) YES Proportion of employees time spent on
project
DATE
YES Starting date for employees activity on
project
DATE
YES Ending date for employees activity on
project

CODE
TIME_SPENT

START_DATE
END_DATE

NO
NO
NO

Copyright IBM Corporation 2007

Figure 2-5. Tables ON_PROJECT and ACTIVITY

CV8317.0

Notes:

The rows in the ON_PROJECT table describe which employees have been assigned to
which projects independently of activities. Not all employees assigned to a project have
activities for the project.

pr

Ex

cl

Each row of the ACTIVITY table describes an activity performed by an employee for a
project.

2-6

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Table spaces
TYPE

TABLES

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TABLE SPACE

SEGMENTED
(SEGSIZE 4)

TSLOCN

RANGE PARTITIONED
(NUMPARTS 3 and
SEGSIZE 4)
PARTITION BY GROWTH
(MAXPARTITIONS 5
and SEGSIZE 32)

TSEMPL

TSDEPT

SEGMENTED
(SEGSIZE 4)

TSPROJ

LOCATION

EMPLOYEE

DEPARTMENT

1. PROJECT
2. ON_PROJECT
3. ACTIVITY

Copyright IBM Corporation 2007

Figure 2-6. Table spaces

CV8317.0

Notes:

The tables are defined in the following table spaces:


TSLOCN is used to store the LOCATION table

cl

TSEMPL is used to store the EMPLOYEE table

TSDEPT is used to store the DEPARTMENT table

Ex

TSPROJ is used to store the following tables:


- PROJECT

- ON_PROJECT

pr

- ACTIVITY

Copyright IBM Corp. 1993, 2011

Exercise 2. Creating tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-7

Student Exercises

Exercise instructions
Note

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Throughout the exercise, search for ?? within the pdf member provided for each problem
and replace any ?? with your team ID. Not all members will contain ??.

Creating tables

__ 1. Member L2LOCN contains an SQL statement to create the LOCATION table. Edit
the member and specify that the table should be created in table space TSLOCN in
your database.
__ 2. Execute the statement using SPUFI. SQLCODE 0 should be returned.

__ 3. Member L2DEPT contains an SQL statement to create the DEPARTMENT table.


Edit the member and specify that the table should be created in table space
TSDEPT in your database.
__ 4. Execute the statement using SPUFI. SQLCODE 0 should be returned.

__ 5. Member L2PROJ contains an SQL statement to create the PROJECT table. Edit the
member and specify that the table should be created in table space TSPROJ in your
database.
__ 6. Execute the statement using SPUFI. SQLCODE 0 should be returned.

__ 7. Member L2ONPROJ contains an SQL statement to create the ON_PROJECT table.


Edit the member and specify that the table should be created in table space
TSPROJ in your database.
__ 8. Execute the statement using SPUFI. SQLCODE 0 should be returned.

cl

__ 9. Member L2ACTY contains an SQL statement to create the ACTIVITY table. Edit the
member and specify that the table should be created in table space TSPROJ in your
database.

Ex

__ 10. Execute the statement using SPUFI. SQLCODE 0 should be returned.

pr

__ 11. Create an SQL statement to create the EMPLOYEE table. The name, data type,
length, and null attribute for each column are shown in the visual on Table
EMPLOYEE on page 2-4. Take care to make sure that you specify the columns
correctly. In addition, specify a table check constraint, which ensures that column
SEX can only have a value of 'F' or 'M'.
Enable table-controlled partitioning using EMPNO as the key column and specify
the limit key values for the three partitions as follows:
'000150' for partition 1
'000230' for partition 2
2-8

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

'001000' for partition 3

EXempty

Create the table in table space TSEMPL in your database.


__ 12. Execute the statement using SPUFI. SQLCODE 0 should be returned.

Querying the DB2 catalog tables

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 13. Execute member L2QUERY1 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSTABLES), explain the meaning of the values held for each column.

__ 14. Execute member L2QUERY2 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSTABLESPACE), explain the meaning of the values held for each
column.
__ 15. Execute member L2QUERY3 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSCOLUMNS), explain the meaning of the values held for each column.

Optional labs

__ 16. Query the two catalog tables which document the check constraint you have
defined.

__ 17. Query the appropriate catalog table to verify the external and internal limit keys for
your table-controlled partition table.

pr

Ex

cl

End of exercise

Copyright IBM Corp. 1993, 2011

Exercise 2. Creating tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

2-9

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

2-10 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 3. Creating and using views


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with creating and using views.

What you should be able to do

At the end of the exercise, you should be able to:


Create views

Explain how SELECT, INSERT, UPDATE, and DELETE statements


are processed when executed against a view
- Especially if the CHECK OPTION is involved

pr

Ex

cl

Derive from the catalog that a DML operation cannot be performed


on a view

Copyright IBM Corp. 1993, 2011

Exercise 3. Creating and using views

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-1

Student Exercises

Exercise instructions
Note

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Throughout the exercise, search for ?? within the pdf member provided for each problem
and replace any ?? with your team ID. Not all members will contain ??.

Creating and using views

__ 1. Examine member L301 which contains an SQL statement to create view V1. A table
called EMP has already been created for you to use in this exercise and the table
has been loaded with data. The definition of EMP is the same as table EMPLOYEE
which is documented on page 2-4.
__ 2. Execute member L301 using SPUFI. SQLCODE 0 should be returned.

__ 3. Execute member L302 using SPUFI and examine the rows returned by each query.
__ 4. Examine member L303 which inserts two rows into table EMP using view V1. Note
that the first row inserted has a SALARY column value less than 20000, and the
second row inserted has a SALARY column value greater than 20000.
__ 5. Execute member L303 using SPUFI. Why are both INSERTs successful?

__ 6. Execute member L302 using SPUFI and examine the rows returned by each query.
__ 7. Execute member L304 using SPUFI. Why is the row deleted?

__ 8. Execute member L305 using SPUFI. Why is the row not found?

__ 9. Execute member L302 using SPUFI and examine the rows returned by each query.
Notice that the row with a SERIAL_NUMBER of 000360 is not returned by the first
query.

cl

__ 10. Execute member L306 using SPUFI. Why is the row updated?

__ 11. Execute member L307 using SPUFI. Why is the row not found?

Ex

__ 12. Execute member L302 using SPUFI and examine the rows returned by each query.
Notice that the row with a SERIAL_NUMBER of 000260 is no longer returned by the
first query.

pr

__ 13. Examine member L308 which contains an SQL statement to create view V2. Notice
that the view definition contains the WITH CHECK OPTION clause.
__ 14. Execute member L308 using SPUFI. SQLCODE 0 should be returned.
__ 15. Execute member L309 using SPUFI. Why does the second INSERT fail?
__ 16. Execute member L310 using SPUFI. Why does the second UPDATE fail?

3-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

__ 17. Examine member L311 which contains an SQL statement to create view V3. Notice
that the view definition does not include column EDUCATION.
__ 18. Execute member L311 using SPUFI. SQLCODE 0 should be returned.
__ 19. Execute member L312 using SPUFI. Why does the INSERT fail?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 20. Execute member L3QUERY1 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSTABAUTH), explain the meaning of the values held for each column.

pr

Ex

cl

End of exercise

Copyright IBM Corp. 1993, 2011

Exercise 3. Creating and using views

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

3-3

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

3-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 4. Creating indexes


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with creating indexes.

What you should be able to do

At the end of the exercise, you should:

Be able to create different types of indexes:


- Unique and non-unique
- Clustering

- Partitioning
- Partitioned

pr

Ex

cl

Be familiar with the type of information held in the DB2 catalog for
indexes

Copyright IBM Corp. 1993, 2011

Exercise 4. Creating indexes

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

4-1

Student Exercises

Exercise instructions
Creating indexes
Index Name

Key Columns

LOCATION

IXLOCN1

LOCID

Unique

Clustering

Yes

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Table Name

DEPARTMENT

IXDEPT1

DEPTNO

DEPARTMENT

IXDEPT2

MGRNO

DEPARTMENT

IXDEPT3

SUPERIOR_DEPTNO

EMPLOYEE

IXEMPL1

EMPNO

EMPLOYEE

IXEMPL2

DEPTNO

EMPLOYEE

IXEMPL3

LOCID

PROJECT

IXPROJ1

PROJNO

PROJECT

IXPROJ2

DEPTNO

PROJECT

IXPROJ3

EMPNO

ON_PROJECT

IXONPR1

PROJNO,EMPNO

ON_PROJECT

IXONPR2

EMPNO

ACTIVITY

IXACTY1

PROJNO,EMPNO,SEQNO

ACTIVITY

IXACTY2

EMPNO

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Yes

cl

__ 1. Create CREATE INDEX statements to define the first 4 indexes listed in the above
table. For each index, specify only the attributes which are stated in the table. All
indexes should be defined as ascending (which is the default). Execute the
statements using SPUFI.

Ex

__ 2. In contrast to working interactively using SPUFI, perform this step in batch: Submit
the job containing the DB2 sample program DSNTEP2 (in member L4CREATE) to
create the remaining 10 indexes listed in the above table. Thereby ensure that:

__ a. The index IXEMPL1 consists of as many data sets as its underlying table space.

pr

__ b. DB2 tries to store the EMPLOYEE data according to the sequence of this index
IXEMPL1.
__ c. The index IXONPR1 is defined as requested.
Use SDSF to see the job output and check for successful execution.

4-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Querying the DB2 catalog tables


__ 3. Execute member L4QUERY1 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(table SYSIBM.SYSINDEXES), explain the meaning of the values held for the
selected columns.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 4. Execute member L4QUERY2 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(table SYSIBM.SYSINDEXPART), explain the meaning of the values held for the
selected columns.
__ 5. Execute member L4QUERY3 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(table SYSIBM.SYSKEYS), explain the meaning of the values held for the selected
columns.

Optional labs:

__ 6. Using DB2I, option 7, display the status of your database and its table spaces and
index spaces via the DB2 command -DISPLAY DATABASE (..).
__ 7. List the VSAM clusters of your table spaces and index spaces.

pr

Ex

cl

End of exercise

Copyright IBM Corp. 1993, 2011

Exercise 4. Creating indexes

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

4-3

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

4-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 5. Creating referential structures


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with defining a referential structure.

What you should be able to do

At the end of the lab, you should:


Be able to define:
- Primary keys
- Foreign keys

pr

Ex

cl

Be familiar with the type of information held in the DB2 catalog for a
referential structure.

Copyright IBM Corp. 1993, 2011

Exercise 5. Creating referential structures

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-1

Student Exercises

Referential structure
LOCATION

LOCID

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

NA

EMPLOYEE

DEPTNO

LOCID

EMPNO

SN

NA

DEPARTMENT

PROJECT

SN

SUPERIOR_
DEPTNO

PROJNO

DEPTNO

MGRNO

NA

NA

DEPTNO

EMPNO
C

ON_PROJECT

PROJNO

EMPNO

ACTIVITY

PROJNO

EMPNO

SEQNO

Copyright IBM Corporation 2007

Figure 5-1. Referential structure

CV8317.0

Notes:

The visual shows the referential structure which will be defined in this exercise. The
primary keys are shown by the dark boxes, and each arrow points from a primary key to a
foreign key. The notation used for the referential delete rules is as follows:

cl

1. 'NA' stands for NO ACTION

Ex

2. 'SN' stands for SET NULL


3. 'C' stands for CASCADE

pr

Take time to study the visual before you start the exercise. The exercise instructions begin
on the next page.

5-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise instructions
Defining primary keys
Primary Key Columns

Primary Key Constraint Name

LOCATION

LOCID

LOCID

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Parent Table

DEPARTMENT

DEPTNO

DEPTNO

EMPLOYEE

EMPNO

EMPNO

PROJECT

PROJNO

PROJNO

ON_PROJECT

PROJNO,EMPNO

PROJNO_EMPNO

ACTIVITY

PROJNO,EMPNO,SEQNO

PROJNO_EMPNO_SEQNO

__ 1. Create ALTER TABLE statements to define the primary key for each of the tables
listed above. Make sure that you remember to specify the Primary Key Constraint
Name. Execute the statements using SPUFI.

pr

Ex

cl

The exercise continues on the next page ...

Copyright IBM Corp. 1993, 2011

Exercise 5. Creating referential structures

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

5-3

Student Exercises

Defining foreign keys and delete rules


Dependent
Table

Foreign Key Columns

Referential
Constraint
Name

Delete Rule

DEPARTMENT

DEPARTMENT

SUPERIOR_DEPTNO

DD

NO ACTION

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Parent Table

EMPLOYEE

DEPARTMENT

MGRNO

ED

SET NULL

LOCATION

EMPLOYEE

LOCID

LE

NO ACTION

DEPARTMENT

EMPLOYEE

DEPTNO

DE

SET NULL

DEPARTMENT

PROJECT

DEPTNO

DP

NO ACTION

EMPLOYEE

PROJECT

EMPNO

EP

NO ACTION

EMPLOYEE

ON_PROJECT

EMPNO

EO

CASCADE

PROJECT

ON_PROJECT

PROJNO

PO

CASCADE

ON_PROJECT

ACTIVITY

PROJNO,EMPNO

OA

CASCADE

__ 2. Create ALTER TABLE statements to define the first 2 foreign keys listed in the
above table (that is, where DEPARTMENT is the dependent table). Make sure that
you remember to specify the referential constraint name. Execute the statements
using SPUFI.
__ 3. Execute member L5ALTER using SPUFI to define the remaining 7 foreign keys
listed in the above table. Edit this member to ensure that the foreign key on
ACTIVITY is defined as requested.

Querying the DB2 catalog tables

Ex

cl

__ 4. Execute member L5QUERY1 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(tables SYSIBM.SYSTABCONST, SYSIBM.SYSKEYCOLUSE, and
SYSIBM.SYSRELS), explain the meaning of the values held for the selected
columns.

pr

Optional lab

__ 5. In which catalog table exists one row per foreign key column? ________________
Query this table for your foreign key columns. How many rows pertain to your 9
referential relationships? ___ Why? ___________________________________

End of exercise
5-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 6. Loading and unloading tables


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience on


loading several tables, with a lot of specialties to consider, such as
when dealing with a multi-table table space. Moreover, you learn to
load tables, which are referentially connected, and to preserve the
referential integrity among these tables. You will also unload data from
a table.

What you should be able to do

At the end of the exercise, you should be able to:

Run the following utilities and correctly use a variety of their


respective options:
- LOAD

- CHECK DATA

pr

Ex

cl

- UNLOAD

Copyright IBM Corp. 1993, 2011

Exercise 6. Loading and unloading tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-1

Student Exercises

Exercise instructions
Note

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Throughout the exercise, search for ?? within the pdf member provided for each problem
and replace any ?? with your team ID. Not all members will contain ??.

Creating a LOAD utility control statement


Column Name

Input Field Position

LOCID

001:010

ADDRESS

011:040

CITY

041:070

POSTAL_CODE

071:085

COUNTRY

086:115

__ 1. Create a member called L6TSLOCN in your CV83.CNTL library which contains a


LOAD utility control statement to load data into the LOCATION table. The above
table describes the layout of the records in the input data set. The definition of the
LOCATION table is shown on page 2-2. Be sure to specify the control statement
correctly.
The syntax for the LOAD utility control statement can be found in the Utility Guide
and Reference manual.

Loading the LOCATION table

cl

We are now going to use DB2 Interactive (DB2I) to build a LOAD utility job to load the
LOCATION table.

Ex

Select DB2I on the ISPF Primary Option Menu.

Select DB2I DEFAULTS on the DB2I Primary Option Menu.

You will be presented with DB2I DEFAULTS PANEL 1. Press Enter.

pr

Copy the JOB statement present in member $JC in your CV83.CNTL data set.
Press Enter.

Select UTILITIES on the DB2I Primary Option Menu.


You will be presented with the DB2 UTILITIES panel shown on the next page.

6-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty
DB2 UTILITIES

SSID: DSNB

===>
Select from the following:
1 FUNCTION ===> EDITJCL
2 JOB ID
===> userid
3 UTILITY ===> LOAD

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

(SUBMIT job, EDITJCL, DISPLAY, TERMINATE)


(A unique job identifier string)
(CHECK DATA, CHECK INDEX, CHECK LOB,
COPY, DIAGNOSE, LOAD, MERGE, MODIFY,
QUIESCE, REBUILD, RECOVER, REORG INDEX,
REORG LOB, REORG TABLESPACE, REPORT,
REPAIR, RUNSTATS, STOSPACE, UNLOAD)
4 STATEMENT DATA SET ===> CV83.CNTL(L6TSLOCN)

5 RESTART ===> NO

(NO, CURRENT, PHASE or PREVIEW)

6 LISTDEF? (YES|NO) ===> NO


TEMPLATE? (YES|NO) ===> NO
7 lib == >
(BLANK or DB2 Library name).
* The data set names panel will be displayed when required by a utility.
F1=HELP
F2=SPLIT
F3=END
F4=RETURN
F5=RFIND
F6=RCHANGE
F7=UP
F8=DOWN
F9=SWAP
F10=LEFT
F11=RIGHT
F12=RETRIEVE

Fill in field 1 as shown. Choosing this option means that you want to view the JCL
before submitting the utility job.
Fill in field 2 with the value of your TSO userid.

Fill in field 3 with the name of the utility you want to run, which is LOAD.

Fill in field 4 as shown. This is the name of the data set and member which contains
your LOAD utility control statement.

Fill in field 5 as shown.

Fill in the options for field 6 as shown.


Leave field 7 as blank.

cl

Press Enter.

pr

Ex

You will now be presented with the Data Set Names panel shown on the next page.

Copyright IBM Corp. 1993, 2011

Exercise 6. Loading and unloading tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-3

Student Exercises

DATA SET NAMES

SSID: DB26

===>
Enter data set name for LOAD, REORG TABLESPACE, or UNLOAD:
1 RECDSN
===> CV83.TSLOCN.DATA

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Enter data set name for LOAD or REORG TABLESPACE:


2 DISCDSN ===> CV83.TSLOCN.DISCARD

Enter output data sets for local/current site for COPY, MERGECOPY,
LOAD, or REORG TABLESPACE:
3 COPYDSN ===>
4 COPYDSN2 ===>
Enter output data sets for recovery site for COPY, LOAD, or REORG
TABLESPACE:
5 RCPYDSN1 ===>
6 RCPYDSN2 ===>
Enter output data sets for REORG or UNLOAD
7 PUNCHDSN ===>
F1=HELP
F7=UP

F2=SPLIT
F8=DOWN

F3=END
F9=SWAP

F4=RETURN
F10=LEFT

F5=RFIND
F11=RIGHT

F6=RCHANGE
F12=RETRIEVE

Fill in field 1 as shown. This is the name of the data set which contains the records to be
loaded.
Fill in field 2 as shown. This is the name of the data set to be used for discard
processing.
Blank out fields 3, 4, 5, 6, and 7.
Press Enter.

After you have viewed the utility job, specify SUBMIT on the editor command line to
submit the job.

cl

Press PF3 to return to the DB2 Utilities panel.

pr

Ex

The utility should end with return code 0. Use SDSF to view the utility output.

6-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Loading DEPARTMENT and EMPLOYEE (a cycle)


The LOAD utility control statements required to load the remaining tables are provided. You
might find it useful to refer to page 2-7 and page 5-2 during this exercise.
__ 2. The utility control statement to load the DEPARTMENT table is supplied in member
L6TSDEPT. First have a look at the contents of this member.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 3. How does the LOAD utility know when to set the MGRNO column value for a row to
NULL?
__ 4. How does the LOAD utility know the length of the input data for column NAME?
__ 5. Should the control statement specify ENFORCE CONSTRAINTS (which is the
default) or ENFORCE NO? Edit member L6TSDEPT accordingly.

__ 6. Using DB2I, prepare a utility job to load the DEPARTMENT table. The name of the
data set which contains the records to be loaded is CV83.TSDEPT.DATA, and the
name of the data set to be used for discard processing is CV83.TSDEPT.DISCARD.
__ 7. Submit the utility job. The utility should end with return code 4.

__ 8. Use SDSF to view the utility output. Why were two rows deleted during the
INDEXVAL phase? Has table space TSDEPT been placed in a pending state?
__ 9. Select DB2 COMMANDS on the DB2I panel.

__ 10. Execute a -DISPLAY DATABASE command to confirm that table space TSDEPT has
been placed in a pending status. The pending status will be corrected in Steps 15
to 23.
__ 11. The utility control statement to load the EMPLOYEE table is supplied in member
L6TSEMPL. Why can the control statement specify (by default) ENFORCE
CONSTRAINTS?

cl

__ 12. Using DB2I, prepare a utility job to load the EMPLOYEE table. The name of the data
set which contains the records to be loaded is CV83.TSEMPL.DATA, and the name
of the data set to be used for discard processing is CV83.TSEMPL.DISCARD.
__ 13. Submit the utility job. The utility should end with return code 4.

pr

Ex

__ 14. Use SDSF to view the utility output. Why were three rows discarded during the
RELOAD phase? Why were three rows deleted during the ENFORCE phase?

Copyright IBM Corp. 1993, 2011

Exercise 6. Loading and unloading tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-5

Student Exercises

Checking the cycle via CHECK DATA

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 15. Recall that table space TSDEPT is in check pending state. You should run the
CHECK DATA utility to remove the check pending state. However, before running
the CHECK DATA utility against table space TSDEPT, you need to create exception
tables for the dependent tables. Edit member L6EXCEPT, change all occurrences of
?? to your team ID, and make a note of the names of the exception tables. Execute
the statements using SPUFI. SQLCODE 0 should be returned.

Steps 16 to 19 are optional.

__ 16. Create a member which contains a CHECK DATA utility control statement to check
table space TSDEPT. Specify the DELETE NO option.

__ 17. Using DB2I, prepare a utility job to run the CHECK DATA utility, and submit the utility
job. The utility should end with return code 4.
__ 18. Use SDSF to view the utility output. Has table space TSDEPT remained in check
pending status? How many rows has CHECK DATA found to be invalid, and why?
__ 19. Execute member L6SELECT using SPUFI to query the contents of the exception
tables for DEPARTMENT and EMPLOYEE.

__ 20. Create a member which contains a CHECK DATA utility control statement to check
table space TSDEPT. Specify the DELETE YES option.

__ 21. Using DB2I, prepare a utility job to run the CHECK DATA utility and submit the utility
job. The utility should end with return code 4.
__ 22. Use SDSF to view the utility output. Verify that table space TSDEPT is no longer in
check pending status. How many rows has CHECK DATA deleted from table
DEPARTMENT, and why?

cl

__ 23. Execute member L6SELECT using SPUFI to query the contents of the exception
tables for DEPARTMENT and EMPLOYEE. Try to explain why CHECK DATA
deleted the rows which are listed for the second run of the utility.

Ex

Loading the remaining tables: PROJECT, ON_PROJECT, and ACTIVITY

pr

__ 24. Using DB2I, prepare a utility job to load the PROJECT table. The utility control
statement is supplied in member L6TSPRJ1. The name of the data set which
contains the records to be loaded is CV83.TSPROJ.DATA1, and the name of the
data set to be used for discard processing is CV83.TSPROJ.DISCARD1.

__ 25. What is the purpose of using the keyword STATISTICS in the LOAD utility control
statement when loading the PROJECT table?
__ 26. Submit the utility job. The utility should end with return code 0.
__ 27. Use SDSF to view the utility output.

6-6

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

__ 28. Using DB2I, prepare a utility job to load the ON_PROJECT and ACTIVITY tables.
The utility control statement is supplied in member L6TSPRJ2. The name of the
data set which contains the records to be loaded is CV83.TSPROJ.DATA2, and the
name of the data set to be used for discard processing is
CV83.TSPROJ.DISCARD2.
__ 29. Submit the utility job. The utility should end with return code 8.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 30. Use SDSF to view the utility output.

__ 31. Why did the utility fail? Edit member L6TSPRJ2 and add an option so that the LOAD
utility adds to the existing data already present in table space TSPROJ.
__ 32. Submit the utility job. The utility should end with return code 0.
__ 33. Use SDSF to view the utility output.

Answer the following questions without actually working on the system:

a. Can the REPLACE option of the LOAD utility be used to replace the existing data for
the ON_PROJECT and ACTIVITY tables while preserving the data for the
PROJECT table?
b. How was the use of REPLACE option appropriate when the PROJECT table data
was loaded?

c. Assuming you have reset the ACTIVITY table, can you repeat steps 28 to 30 to load
the ON_PROJECT and ACTIVITY tables?

Understanding partition by growth universal table space

cl

__ 34. Create a partition by growth universal table space named TSNEWDEP in your
database. The maximum data set size should be 1 GB and TSNEWDEP should be
able to grow up to a maximum of 5 partitions. Also, specify that you want 99 percent
of each page to be left as free space and every other page should be a page of free
space when the table space or partition is loaded or reorganized. Create table
NEWDEPT which is identical to your table DEPARTMENT, but without any primary
or foreign keys, in the table space TSNEWDEP in your database. Use member
L6PBG1.

Ex

__ 35. Examine the catalog tables to note the important information for table space
TSNEWDEP in your database. Use member L6PBG2.
__ 36. How many partitions are created?

pr

Determine this from the catalog table information and also using ISPF 3.4 by using
DBDSNB.DSNBB*.WWV83??D.TSNEWDEP (where ?? is your team-id) to narrow
the search.

__ 37. Using DB2I, prepare and run a utility job to load the NEWDEPT table. The utility
control statement is in member L6PBG3. The name of the data set which contains

Copyright IBM Corp. 1993, 2011

Exercise 6. Loading and unloading tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-7

Student Exercises

the records to be loaded is CV83.TSNEWDEP.DATA, and the name of the data set
to be used for discard processing is CV83.TSNEWDEP.DISCARD.
Please be patient as it will take a few minutes to complete.
__ 38. After the successful completion of the LOAD utility, how many partitions do you see?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Determine this from the utility output messages and also using ISPF 3.4 by using
DBDSNB.DSNBB*.WWV83??D.TSNEWDEP (where ?? is your team-id) to narrow
the search.

__ 39. Drop the table space TSNEWDEP in your database. Use member L6PBG4.

Unloading data

__ 40. Create a member called L6UNLOAD in your CV83.CNTL library with an UNLOAD
utility control statement to unload data in EBCDIC from the table space TSPROJ.

Specify CV83.TSPROJ.UNLOAD.DATA and CV83.TSPROJ.UNLOAD.PUNCH for


the unload and punch data sets. Examine what these contain after the UNLOAD
utility completes successfully.

Optional lab steps

__ 41. Try to unload from TSPROJ in delimited format (at least from table PROJECT). Use
the default characters for column delimiter, string delimiter, and decimal point. In
order not to override the previous data sets, specify new names for the unload and
punch data sets.
Examine what these data sets contain after the UNLOAD utility completes
successfully.

__ 42. Lets unload from a view.

__ a. To this end, create a view which lists the department by employees, and the
manager who is responsible for this department:

pr

Ex

cl

---------+---------+---------+---------+----EMPNO
LAST_NAME
DEPTNO MGRNO
MGRNAME
---------+---------+---------+---------+----000010 HAAS
A00
000010 HAAS
000110 LUCCHESI
A00
000010 HAAS
000120 O'CONNELL
A00
000010 HAAS
000020 THOMPSON
B01
000020 THOMPSON
000030 KWAN
C01
000030 KWAN
....

(You may create the view on your own or use the member L6VIEW provided.)

__ b. Use the DB2 sample program DSNTIAUL for unloading; see member L6TIAUL.
Add a second query involving a join into the same job. (Each SQL statement
must end with a semicolon.) DSNTIAUL generates separate output data sets per

6-8

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

query and one additional data set with pertinent LOAD statements. Specify some
meaningful output data set names (the provided DDNAMEs are fixed).

EXempty

__ c. Inspect the three output data sets. Can you use the generated LOAD statements
without modification? ____ Why? ___________________________________

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 43. In order to consolidate what you learned about the data page structure, use the DB2
stand-alone utility DSN1PRNT to print the contents of your table space TSDEPT.
(Hint: use provided member L6PRINT.) Provide DSN1PRNT parameters in the form:
PARM='PRINT(f,l),EBCDIC,FORMAT', where f, l are the numbers of the first and
last page respectively to print (f,l in hexadecimal format).
__ a. What did you specify for SYSUT1? _________________________________
__ b. Which values did you use for f, l? ____, ____

__ c. How many pages were printed? ________ What kind of pages?


______________________________________________________________
__ d. Look for the ID MAP in the data page. How many entries (records) do you find
there? ______
__ e. Look for HOLEs: How many do you find? ______
__ f.

Explain the number of holes: _______________________________________

__ g. Verify what you found out by comparing it with the number of rows (= ________)
in the table space TSDEPT by selecting from its tables.

__ h. According to the DSN1PRNT output, what is the OBID of the table (PGSOBD) to
which the rows belong? _______ Compare this with the OBID of the table in
TSDEPT, as recorded in the DB2 catalog.
Find the prefix of the first two rows. What are the row lengths (PGSLTH)?
_____,_____ Why different? ______________________________________

__ j.

Insert a row with maximal length (use member L6INSERT). What is the length of
the row according to the DB2 catalog? ______ Stop and start the table space,
then issue the DSN1PRNT job again. What is the length of the newly-inserted
record according to the job output? ______ Why different?

Ex

cl

__ i.

pr

End of exercise

Copyright IBM Corp. 1993, 2011

Exercise 6. Loading and unloading tables

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

6-9

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

6-10 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 7. Running RUNSTATS and REORG


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


concerning the following questions:

1. When and how should I retrieve statistics about a table space and
its indexes and store these statistics in the catalog?
2. When and how should I reorganize a table space?

What you should be able to do

At the end of the exercise, you should be able to:

Select from the catalog table SYSIBM.SYSTABLESPACESTATS


and correctly interpret the results

pr

Ex

cl

Run the RUNSTATS and the REORG utilities and use a variety of
their respective options

Copyright IBM Corp. 1993, 2011

Exercise 7. Running RUNSTATS and REORG

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-1

Student Exercises

Exercise instructions
Note

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Throughout the exercise, search for ?? within the provided pdf member for each problem
and replace any ?? with your team ID. Not all members will contain ??.

Use real-time statistics to determine the need for RUNSTATS

__ 1. Examine member L7QUERY1. Execute the statement using SPUFI. What is the
query doing? By referring to DB2 catalog tables section in the Appendix of SQL
Reference explain the meaning of the values held for each column, and complete
the following table:
Table 1: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space
TSPROJ
TOTALROWS

STATSINSERTS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

__ 2. Is TOTALROWS what you expect?


Hint

Refer to the solution of Exercise 6 and look at the LOAD output for all tables in table
space TSPROJ.

__ 3. Explain the STATSINSERTS value.

Ex

cl

__ 4. Based on the values in table 1, would you recommend to run RUNSTATS on table
space TSPROJ, if your rule of thumb is to run RUNSTATS if at least 20% of the table
space content has changed?

pr

__ 5. Before running RUNSTATS, let us do another change to the content of one of the
tables in table space TSPROJ. First, examine member L7UPDATE, then execute
this member using SPUFI. What type of disorganization might this introduce into the
table space?

__ 6. The previous step contained a query after the UPDATE statement. According to the
result of that query, did any values change compared to table 1? Why not? When
will STATSUPDATES reflect the 120 rows updated by query L7UPDATE? Be
patient, it could take several minutes for STATSUPDATES to reflect the change. The
time it takes depends on the interval STATSINT set in zparm.

7-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty
Table 2: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space
TSPROJ
TOTALROWS

STATSINSERTS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 7. After a while, execute member L7QUERY1. Is STATSUPDATES now what you


expect?
Table 3: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space
TSPROJ
TOTALROWS

STATSINSERTS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

Perform a RUNSTATS

__ 8. Create a RUNSTATS utility control statement to:

__ a. Update the DB2 catalog tables with all statistics for table space TSPROJ and all
indexes.

__ b. The collected statistics should also be reported in the job output.

__ c. Allow read and write applications to execute while the utility is running.

__ 9. Using DB2I, prepare a utility job to run the RUNSTATS utility and submit the utility
job. The utility should end with return code 0.

cl

__ 10. Use SDSF to view the utility output. By referring to the RUNSTATS report and to
DB2 Catalog Tables topic in Appendix "Additional Information for DB2 SQL" of the
SQL Reference, complete the following tables and explain the meaning of the
values held for each column in these tables:
Table 4: SYSIBM.SYSTABLEPART Catalog Statistics

Ex

CARDF

NEARINDREF

FARINDREF

Table 5: SYSIBM.SYSINDEXPART Catalog Statistics


CARDF

pr

Index Name

NEAROFFPOSF

FAROFFPOSF

LEAFFAR

IXPROJ3
IXPROJ1
IXPROJ2

Copyright IBM Corp. 1993, 2011

Exercise 7. Running RUNSTATS and REORG

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-3

Student Exercises

Table 5: SYSIBM.SYSINDEXPART Catalog Statistics


Index Name

CARDF

NEAROFFPOSF

FAROFFPOSF

LEAFFAR

IXONPR2
IXONPR1

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

IXACTY1
IXACTY2

__ 11. Execute L7QUERY1 to cross-check with the real-time statistics to see if you get the
same values. By the way, why are STATSINSERTS and STATSUPDATES now 0?
Table 6: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space
TSPROJ
TOTALROWS

STATSINSERTS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

__ 12. Have any variable length rows overflowed to another page?

__ 13. Why is the data for the PROJECT table still reported as being well-clustered even
though a number of rows in the PROJECT table have overflowed?

Use catalog statistics to conditionally perform a REORG

You can use the real-time statistics counters for determining whether to perform a REORG.
However, you will now learn how to use the catalog statistics, gathered by running the
RUNSTATS utility, to determine if there is a need to perform reorganization of table space
TSPROJ in your database.

cl

__ 14. Prepare a REORG TABLESPACE utility control statement to reorganize table space
TSPROJ. Specify an OFFPOSLIMIT and INDREFLIMIT of 15. Also specify that a
REORG should not be performed but that the utility should report whether or not a
REORG is recommended.

Ex

__ 15. Using DB2I, prepare a utility job to run the REORG TABLESPACE utility. The name
of the unload data set (field 1 of the Data Set Names panel) should be
CV83.TSPROJ.UNLOAD. All other fields on the Data Set Names panel should be
blanked out.

pr

__ 16. Submit the utility job. The utility should end with return code 1. Use SDSF to view
the utility output. Why does the utility end with return code 1?

__ 17. Modify your REORG TABLESPACE utility control statement and specify an
OFFPOSLIMIT and INDREFLIMIT of 10. Again, a REORG should not be performed
but the utility should report whether or not a REORG is recommended.

7-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

__ 18. Submit the utility job. The utility should end with return code 2. Use SDSF to view
the utility output. Which REORG limit has been met?
__ 19. Modify your REORG TABLESPACE utility control statement again so that a REORG
is performed if the OFFPOSLIMIT or INDREFLIMIT of 10 is exceeded. In addition,
specify that REORG should gather statistics for table space TSPROJ and all
indexes. The job output should contain the statistics figures.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 20. Submit the utility job and use SDSF to view the utility output. The utility should end
with return code 2. By referring to the REORG report, complete the following tables:
Table 7: SYSIBM.SYSTABLEPART Catalog Statistics
CARDF

NEARINDREF

FARINDREF

Table 8: SYSIBM.SYSINDEXPART Catalog Statistics


Index Name

CARDF

NEAROFFPOSF

FAROFFPOSF

LEAFFAR

IXPROJ3
IXPROJ1

IXPRPOJ2
IXONPR2
IXONPR1
IXACTY1
IXACTY2

pr

Ex

cl

__ 21. NEARINDREF and FARINDREF should now both be 0.

Copyright IBM Corp. 1993, 2011

Exercise 7. Running RUNSTATS and REORG

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

7-5

Student Exercises

Optional steps:
__ 22. Calculate how much space is needed for TSPROJ:
__ a. Determine how many segments are needed just for the PROJECT table alone.
Then determine the total number of pages needed for TSPROJ.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ b. Calculate the number of tracks needed (on a 3390 volume, a track can store
48 KB).

__ c. For such a small table space, the actual space allocated greatly depends on the
environment, such as the zparm TSQTY. Here, 1 cylinder (= 15 tracks) is
allocated.
Verify this by executing the IDCAMS command LISTCAT.
(Use member L7LISTC.)

__ 23. Restarting a utility, here REORG:

__ a. Simulating a typing error, enlarge the primary allocation for the index IXLOCN1
on LOCATION to the extreme value 999999999.

__ b. Try to reorganize the TSLOCN table space. (The job will of course fail because
of the index space.) Check whether you can still retrieve data from the
LOCATION table. Display the status of the database and of the REORG utility.
Which phases of the REORG have been completed?
______________________________ Check whether the unloaded data exists.

__ c. Correct the problem and restart the utility. Be sure to change neither the utility ID
nor the utility control statement nor the sysrec data set name. Which REORG
phases are performed by this second job?
Note that there is no need to specify RESTART. When the job is submitted, DB2
automatically figures out if it is normal execution or restart. If it is restart, it also
figures out if it should be phase restart or current restart.

Ex

cl

______________________________________________________________
Again, check the status of the database and verify that you can query the data.

pr

End of exercise

7-6

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 8. Running COPY and RECOVER


What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with creating backup copies of table spaces and recovering physically
corrupted table spaces to the current point in time.

What you should be able to do

At the end of the exercise, you should be able to:


Run the COPY utility with various options

pr

Ex

cl

Run the RECOVER utility in its basic form and explain its job output

Copyright IBM Corp. 1993, 2011

Exercise 8. Running COPY and RECOVER

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-1

Student Exercises

Exercise instructions
Running the COPY utility

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 1. Create a COPY utility control statement to create a local primary and a local backup
FULL image copy of table space TSEMPL. Specify SYSCOPY for the local primary
DDNAME and SYSCOPY2 for the local backup DDNAME. (These are the
DDNAMEs generated by the Data Set Names panel of DB2I.)
__ 2. Using DB2I, prepare a utility job to run the COPY utility. The image copy data sets
should be named CV83.TSEMPL.FIC1A for the local primary (field 3 of the Data Set
Names panel) and CV83.TSEMPL.FIC1B for the local backup (field 4 of the Data Set
Names panel). All other fields on the Data Set Names panel should be blanked out.
__ 3. Submit the utility job and use SDSF to view the utility output. The utility should end
with return code 0.
__ 4. Execute member L8UPDATE using SPUFI. This UPDATE statement updates one
row in partition 1 and one row in partition 3.

__ 5. Create a COPY utility control statement to create a local primary and a local backup
INCREMENTAL image copy of table space TSEMPL. Specify SYSCOPY for the
local primary DDNAME and SYSCOPY2 for the local backup DDNAME. (These are
the DDNAMEs generated by the Data Set Names panel of DB2I.)
__ 6. Using DB2I, prepare a utility job to run the COPY utility. The image copy data sets
should be named CV83.TSEMPL.IIC1A for the local primary (field 3 of the Data Set
Names panel) and CV83.TSEMPL.IIC1B for the local backup (field 4 of the Data Set
Names panel). All other fields on the Data Set Names panel should be blanked out.
__ 7. Submit the utility job and use SDSF to view the utility output. The utility should end
with return code 0.
__ 8. Execute member L8UPDATE using SPUFI.

cl

__ 9. Edit member L8QUERY1 and change ?? to your team ID.

pr

Ex

__ 10. Execute member L8QUERY1 using SPUFI. By referring to DB2 Catalog Tables topic
in Appendix "Additional Information for DB2 SQL" of the SQL Reference manual
(SYSIBM.SYSCOPY), explain the meaning of the values held for each column.

8-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Running the RECOVER utility


__ 11. Create a RECOVER utility control statement to recover table space TSEMPL.
__ 12. Using DB2I, prepare a utility job to run the RECOVER utility.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 13. Submit the utility job and use SDSF to view the utility output. The utility should end
with return code 0.
__ 14. Which image copies are used by the RECOVER utility?

__ 15. Why must the RECOVER utility apply log records after restoring the image copies?
__ 16. Delete image copy CV83.TSEMPL.IIC1A

__ 17. Submit the RECOVER utility job again, and use SDSF to view the utility output. The
utility should end with return code 0.
__ 18. Explain the response of the RECOVER utility.
__ 19. Delete image copy CV83.TSEMPL.IIC1B

__ 20. Submit the RECOVER utility job again, and use SDSF to view the utility output. The
utility should end with return code 0.
__ 21. Explain the response of the RECOVER utility.

__ 22. Why must the RECOVER utility now apply an additional range of log records?

Optional labs

__ 23. Simulate an I/O error for a single partition of table space TSEMPL itself (rather than
for copy data sets) and recover the table space partition. More precisely:

__ a. Copy only the first partition of TSEMPL. The name of the copy data set should be
userid.CV83.TSEMPL.PART1.FCOPY1.
__ b. Determine the volumes the individual table space partitions reside on (use
member L8LISTC, then look for VOLSER): ________, ________, ________

Ex

cl

__ c. In order to simulate an I/O error, try to delete the VSAM cluster of the first
partition (use member L8DELC). Why does the job fail? ________________
Who is the current user? __________

__ d. How can you delete the current user? _____________________________


(Use DB2I or alternatively member L8DB2CMD.) Then delete the first partition.

pr

__ e. Now a substitution of the defect volume is needed, either by altering the DB2
storage group or by asking the SMS colleagues to replace the volume.
(Remember, we know the volume which is defective.) As this depends on
individual circumstances, we skip this step, pretending the volume has been
replaced.
__ f.

Recover only the first partition of TSEMPL. Which copy data set is used?
___________________________________________________

Copyright IBM Corp. 1993, 2011

Exercise 8. Running COPY and RECOVER

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

8-3

Student Exercises

__ 24. In the optional lab on DSN1PRNT (Exercise 6, Step 43(j)), you were asked to
perform the following steps: run DSN1PRNT, insert a new row, stop the table space,
start the table space, run DSN1PRNT again, and observe the difference in the job
outputs.
Why should you stop and then restart the table space? _____________________
________________________________________________________________

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

You may check what happens if you run the second DSN1PRNT directly after the
INSERT, without stopping and starting the table space.

__ 25. Clean up the system:

__ a. Use the appropriate utility to retrieve all recovery information DB2 has stored for
the table space TSLOCN.
__ b. Delete some old SYSCOPY entries for this table space.

__ c. Retrieve the recovery information again. What differences do you see?


_____________________________________________________________

pr

Ex

cl

End of exercise

8-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 9. Security
What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with DB2 security.

What you should be able to do

At the end of the exercise, you should be able to:


Request and give appropriate grants

Retrieve and work with your primary and secondary authorization


IDs, that is, with USER and CURRENT SQLID

Navigate through the various security tables in the DB2 catalog


and explain where and how security information is stored in DB2

pr

Ex

cl

Create tables for others, with various qualifiers

Copyright IBM Corp. 1993, 2011


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Exercise 9. Security

9-1

Student Exercises

Exercise instructions
Note

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

As usual, replace ?? by your team number.

Privileges on tables you do not own

__ 1. Attempt to SELECT data from your neighbor's EMPLOYEE table. What happens?

__ 2. Ask your neighbor to GRANT you the SELECT privilege on their EMPLOYEE table.
__ 3. Attempt to SELECT data from your neighbor's EMPLOYEE table. What happens
this time?

__ 4. Attempt to DELETE data from your neighbor's EMPLOYEE table. What happens?

RACF groups and current SQLID

The value of your Primary Authid and Current SQLID are each contained in a DB2 special
register called USER and CURRENT SQLID respectively.
__ 5. Determine the value of your Primary Authid and Current SQLID by executing
member L9AUTHID using SPUFI.
__ 6. Is it possible to determine your Secondary Authids using SQL? ________

Execute the TSO command LISTUSER (TSO LU) which lists the RACF group(s) to
which you belong (you are connected to). If the list contains more than one group,
note your so-called default group: ______________. You will use this group in the
following exercises.
(The Connection Exit Routine assigns these groups as your Secondary Authids.)

Ex

cl

__ 7. Use SQL to change your Current SQLID to something different from your Primary
Authid. Remember your Current SQLID can only be changed to either your Primary
Authid or to one of your Secondary Authids.

__ 8. Use L9AUTHID to check your Current SQLID setting.

Determining privileges held by authorization IDs

pr

Certain privileges have been granted on database WWV83XXD (note: XX is really XX) to your
Secondary Authid but not to your Primary Authid. (In the following, use your default
Secondary Authid.)
__ 9. Query the appropriate DB2 catalog tables to determine:
__ a. Which Authid is the owner (creator) of this database.

9-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

__ b. What privileges your Secondary Authid holds on this database.


__ c. Who granted your Secondary Authid these privileges.
__ d. What privileges the database owner holds on the database.

Privileges required to create a table (for example, with different owner)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Before performing the next part of the exercise, you should read the description of the
privilege set required to create a table which is documented in the SQL Reference manual.
Refer to the section which describes the CREATE TABLE statement and then read the
information under heading Authorization. (Note that the manual uses the term
SQL authorization ID rather than Current SQLID.)

__ 10. Member L9CRE1 sets your Current SQLID to your Primary Authid and attempts to
create an implicitly qualified table in database WWV83XXD. Execute the member using
SPUFI.
__ 11. What happens and why?

__ 12. Member L9CRE2 sets your Current SQLID to your Secondary Authid and attempts
to create an implicitly qualified table in database WWV83XXD. Execute the member
using SPUFI.
__ 13. What happens and why?

__ 14. Member L9CRE3 sets your Current SQLID to your Primary Authid and attempts to
create an explicitly qualified table in database WWV83XXD. The explicit qualifier is your
Secondary Authid. Execute the member using SPUFI.
__ 15. What happens, and why?

__ 16. Member L9CRE4 sets your Current SQLID to your Secondary Authid and attempts
to create an explicitly qualified table in database WWV83XXD. The explicit qualifier is
your Primary Authid. Edit this member, change xxxxxxx to your Primary Authid, and
then execute the member using SPUFI.

cl

__ 17. What happens, and why?

Ex

Privileges needed for DML

__ 18. Set your Current SQLID to your Primary Authid, and try to SELECT data from table
sauthid.T??A, which you created earlier (where sauthid is your Secondary Authid
and ?? is your team ID).

pr

__ 19. Why is the SELECT successful, even though your Primary Authid does not have
SELECT privilege on table sauthid.T??A?
__ 20. Query the appropriate DB2 catalog table to determine:
__ a. Which Authid owns tables T??A and T??B (where ?? is your team ID).

__ b. Which Schema is used for tables T??A and T??B (where ?? is your team ID).
Copyright IBM Corp. 1993, 2011
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Exercise 9. Security

9-3

Student Exercises

__ 21. Query the appropriate DB2 catalog table to determine which of your Authids has the
privilege to query DB2 catalog table SYSIBM.SYSTABLES.

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

End of exercise

9-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 10.Locking
What this exercise is about

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

This exercise provides an opportunity to gain hands-on experience


with DB2 locking.

What you should be able to do

At the end of the exercise, you should be able to:

Explain where locking parameters for a table space, such as lock


size, are documented in the DB2 catalog

Find applications using potentially problematic parameters when it


comes to concurrency, that is, for the RELEASE or ISOLATION
options
Display the current locking situation in a database

pr

Ex

cl

Bypass a lock when selecting data

Copyright IBM Corp. 1993, 2011


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Exercise 10. Locking

10-1

Student Exercises

Exercise instructions
Retrieving locking information from the DB2 catalog
__ 1. Query the relevant DB2 catalog tables to determine:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ a. What lock size is specified for your table spaces


__ b. Whether any application packages exist that will hold table space locks until
deallocation

__ c. Whether any application packages exist that require a repeatable read capability.

Diagnose an unsuccessful lock request

__ 2. Try to execute a SELECT against table WWCV831.DEPARTMENT and wait to see what
happens. What is the reason code you receive? ____________________
Look it up in the Codes manual and explain what it means.
_______________________________________________________________

Displaying locking information for a segmented table space

__ 3. Execute member LAQUERY1 using SPUFI. Note down the name of the database
and table space for table WWCV831.DEPARTMENT. Also note down the object ID (OBID
column value) of the table.
__ 4. Use the appropriate DB2 command to display any locks that are held on the table
space. Look up message DSNT397I in the Messages manual, and use the
information to explain the output of the DISPLAY command.
__ a. Who is holding a lock on the table space, and what is the mode of the lock?
__ b. Who is holding a lock on the table, and what is the mode of the lock?
__ c. When will the locks be freed?

cl

__ d. Is anyone waiting for a lock on the table space or table?

Ex

__ e. Query catalog table SYSIBM.SYSTABLESPACE to find out what lock size was
specified for the table space.

Optional: Displaying locking information for a partitioned table space

pr

__ 5. Use the appropriate DB2 command to display any locks that are held on table space
WWV83YYD.TSEMPL. Again, look up message DSNT397I in the Messages manual,
and use the information to explain the output of the DISPLAY command. Are all
partitions locked? _______

10-2 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Reading uncommitted data


__ 6. Run your SELECT against table WWCV831.DEPARTMENT again (see step 2 above), but
first add the WITH UR option to your SELECT statement.
__ 7. Why is the SELECT now successful?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

__ 8. Run your SELECT against table WWCV831.DEPARTMENT again (see step 6 above), but
first add the SKIP LOCKED DATA option instead of WITH UR to your SELECT
statement. Explain the difference between WITH UR and SKIP LOCKED DATA.

pr

Ex

cl

End of exercise

Copyright IBM Corp. 1993, 2011


Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.

Exercise 10. Locking

10-3

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

10-4 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

Appendix A. Exercise solutions

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-1

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

A-2

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 1: Creating databases and table spaces


Step 1: Creating a database

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE DATABASE WWV8301D


BUFFERPOOL BP1
INDEXBP
BP2
STOGROUP
WWV8301S;

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Steps 2 to 5: Creating table spaces


CREATE TABLESPACE TSLOCN
IN WWV8301D

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE TABLESPACE TSDEPT
IN WWV8301D
SEGSIZE 32
MAXPARTITIONS 5;

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE TABLESPACE TSEMPL
IN WWV8301D
SEGSIZE 4
NUMPARTS 3;

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE TABLESPACE TSPROJ
IN WWV8301D
SEGSIZE 4
PCTFREE 0;

pr

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-3

Student Exercises

Steps 6 to 8: Querying the DB2 catalog tables

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT SUBSTR(NAME,1,8) AS NAME, SUBSTR(CREATOR,1,8) AS CREATOR,


SUBSTR(STGROUP,1,8) AS STGROUP, BPOOL, INDEXBP
FROM SYSIBM.SYSDATABASE
WHERE CREATOR = USER
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+---------+
NAME
CREATOR
STGROUP
BPOOL
INDEXBP
---------+---------+---------+---------+---------+---------+---------+---------+
WWV8301D TSOUB01
WWV8301S BP1
BP2
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
---------+---------+---------+---------+---------+---------+---------+---------+

SELECT SUBSTR(NAME,1,8) AS NAME, SUBSTR(CREATOR,1,8) AS CREATOR,


SUBSTR(DBNAME,1,8) AS DBNAME,
TYPE, BPOOL, PARTITIONS, MAXPARTITIONS,
PGSIZE, STATUS, NTABLES, SEGSIZE
FROM SYSIBM.SYSTABLESPACE
WHERE CREATOR = USER
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+---------+---------+
NAME CREATOR DBNAME TYPE BPOOL PARTITIONS MAXPARTITIONS PGSIZE STATUS NTABLES SEGSIZE
---------+---------+---------+---------+---------+---------+---------+---------+---------+
TSLOCN TSOUB01 WWV8301D
BP1
0
0
4
T
0
4
4
T
0
32
TSDEPT TSOUB01 WWV8301D
G
BP1
1
5
TSEMPL TSOUB01 WWV8301D
R
BP1
3
0
4
T
0
4
TSPROJ TSOUB01 WWV8301D
BP1
0
0
4
T
0
4
DSNE610I NUMBER OF ROWS DISPLAYED IS 4
---------+---------+---------+---------+---------+---------+---------+---------+---------+

pr

Ex

cl

SELECT SUBSTR(TSNAME,1,8) AS TSNAME,


PARTITION, PQTY, STORTYPE,
SUBSTR(STORNAME,1,8) AS STORNAME,
SUBSTR(VCATNAME,1,8) AS VCATNAME,
FREEPAGE, PCTFREE
FROM SYSIBM.SYSTABLEPART
WHERE DBNAME = 'WWV8301D'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+---------+-TSNAME
PARTITION
PQTY STORTYPE STORNAME VCATNAME FREEPAGE PCTFREE
---------+---------+---------+---------+---------+---------+---------+---------+-TSLOCN
0
-1 I
WWV8301S DBDSNB
0
5
TSDEPT
1
-1 I
WWV8301S DBDSNB
0
5
TSEMPL
1
-1 I
WWV8301S DBDSNB
0
5
TSEMPL
2
-1 I
WWV8301S DBDSNB
0
5
TSEMPL
3
-1 I
WWV8301S DBDSNB
0
5
TSPROJ
0
-1 I
WWV8301S DBDSNB
0
0
DSNE610I NUMBER OF ROWS DISPLAYED IS 6
---------+---------+---------+---------+---------+---------+---------+---------+--

A-4

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Remarks: PQTY = -1 indicates that no value has been specified for the primary quantity.
The actual amount of space allocated depends on the TSQTY DSNZPARM value (here:
one cylinder if TSQTY=0).

Optional labs:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Step 9a: Volume IDs according to the DB2 catalog

---------+---------+---------+---------+---------+---------+---------+
SELECT *
FROM SYSIBM.SYSVOLUMES
WHERE SGNAME = 'WWV8301S'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+
SGNAME
SGCREATOR
VOLID
IBMREQD
---------+---------+---------+---------+---------+---------+---------+
WWV8301S
SYSPROG
*
N
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
---------+---------+---------+---------+---------+---------+---------+

In this installation, the storage group has been defined with VOLUMES (*). That means
that SMS routines should determine the volume per data set.

Step 9b: Explicit volume IDs reliable?

No. If SMS routines (so-called ACS routines) are activated, their rules may override even
explicit volume specifications made via the DB2 command CREATE STOGROUP.

Step 10: Data set names of table space TSEMPL

cl

We already know the high-level qualifier DBDSNB from querying SYSTABPLEPART (see
above). As we assume that the name TSEMPL will be preserved in the data set name, we
therefore search for DBDSNB.**.TSEMPL.* in ISPF 3.4 (without TSEMPL would work but
would generate a longer list):
Data Set List Utility

Ex

Option ===>

blank Display data set list


V Display VTOC information

More:
P Print data set list
PV Print VTOC information

pr

Enter one or both of the parameters below:


Dsname Level . . . DBDSNB.**.TSEMPL.*
Volume serial . .

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-5

Student Exercises

The resulting list:


DSLIST - Data Sets Matching DBDSNB.**.TSEMPL.*
Command ===>

Row 1 of 54
Scroll ===> CSR

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Command - Enter "/" to select action


Message
Volume
------------------------------------------------------------------------------DBDSNB.DSNBBC.WWV83YYD.TSEMPL.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV83YYD.TSEMPL.I0001.A002
*VSAM*
DBDSNB.DSNBBC.WWV83YYD.TSEMPL.I0001.A003
*VSAM*
DBDSNB.DSNBBC.WWV83ZZD.TSEMPL.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV83ZZD.TSEMPL.I0001.A002
*VSAM*

...........

Second attempt to narrow down this list (qualifying TSEMPL with its database name):
DSLIST - Data Sets Matching DBDSNB.**.WWV8301D.TSEMPL.*
Command ===>

Row 1 of 6
Scroll ===> CSR

Command - Enter "/" to select action


Message
Volume
------------------------------------------------------------------------------DBDSNB.DSNBBC.WWV8301D.TSEMPL.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSEMPL.I0001.A002
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSEMPL.I0001.A003
*VSAM*
DBDSNB.DSNBBD.WWV8301D.TSEMPL.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.TSEMPL.I0001.A002
SMS012
DBDSNB.DSNBBD.WWV8301D.TSEMPL.I0001.A003
SMS012
***************************** End of Data Set list ****************************

Step 11: Volume ID of TSEMPL, partition 1

As can be seen, the data set of partition 1 of TSEMPL resides on volume SMS012.

Step 12: Why does CREATE TABLESPACE fail?

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
CREATE TABLESPACE TEST01A IN WWV83ZZD ;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -904, ERROR: UNSUCCESSFUL EXECUTION CAUSED BY AN
UNAVAILABLE RESOURCE. REASON 00D70025, TYPE OF RESOURCE 00000220, AND
RESOURCE NAME DBV8ZZZ.DSNBBC.WWV83ZZD.TEST01A.I0001.A001
DSNT418I SQLSTATE
= 57011 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXICTS SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= 105 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'00000069' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

A-6

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

In ssnnMSTR, you see various error messages, for example:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

03.18.48 STC00436 DSNP009I -DSNB THE FOLLOWING ERROR MESSAGES WERE 316
316
RECEIVED FOR DEFINE CLUSTER ON
316
DBV8ZZZ.DSNDBC.WWV83ZZD.TEST01A.I0001.A001
316
IGD17103I CATALOG ERROR WHILE DEFINING VSAM DATA SET
316
DBV8ZZZ.DSNDBC.WWV83ZZD.TEST01A.I0001.A001
316
RETURN CODE IS 56 REASON CODE IS 6 IGG0CLFT
316
IGD306I UNEXPECTED ERROR DURING IGG0CLFT PROCESSING
316
RETURN CODE 56 REASON CODE 6
316
THE MODULE THAT DETECTED THE ERROR IS IGDVTSCU
316
SMS MODULE TRACE BACK - VTSCU VTSCT VTSCH VTSCG VTSCD VTSCC V
316
SSIRT
316
SYMPTOM RECORD CREATED, PROBLEM ID IS IGD00000
316
IGD17219I UNABLE TO CONTINUE DEFINE OF DATA SET
316
DBV8ZZZ.DSNDBC.WWV83ZZD.TEST01A.I0001.A001
316
IDC3018I SECURITY VERIFICATION FAILED
316
IDC3009I ** VSAM CATALOG RETURN CODE IS 56 - REASON CODE IS
316
IGG0CLFT-6
316
IDC3003I FUNCTION TERMINATED. CONDITION CODE IS 12

The System Log produces similar error messages, that is, in these examples, SECURITY
VERIFICATION FAILED, when DB2 tries to define cluster
DBV8ZZZ.DSNBBC.WWV83ZZD.TEST01A.I0001.A001.
Query which volumes are used for the last (unsuccessful) trial and the previous
(successful) trials to create table spaces in databases WWV83ZZD or WWV8301D
respectively:

Ex

cl

---------+---------+---------+---------+---------+---------+-SELECT *
FROM SYSIBM.SYSVOLUMES
WHERE SGNAME IN (SELECT STGROUP
FROM SYSIBM.SYSDATABASE
WHERE NAME IN ('WWV8301D', 'WWV83ZZD') )
WITH UR ;
---------+---------+---------+---------+---------+---------+-SGNAME
SGCREATOR
VOLID
---------+---------+---------+---------+---------+---------+-WWV83ZZS
SYSPROG
*
WWV8301S
SYSPROG
*
DSNE610I NUMBER OF ROWS DISPLAYED IS 2
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+--

In both cases, the storage groups are defined with VOLUMES(*).

pr

So, there must be another reason.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-7

Student Exercises

By looking at the ssnnMSTR or the syslog message:


DBV8ZZZ.DSNBBC.WWV83ZZD.TEST01A.I0001.A001 could not be defined,
now inspect the VCAT specification:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+SELECT NAME, VCATNAME


FROM SYSIBM.SYSSTOGROUP
WHERE NAME IN (SELECT STGROUP
FROM SYSIBM.SYSDATABASE
WHERE NAME IN ('WWV8301D', 'WWV83ZZD') )
WITH UR ;
---------+---------+---------+---------+---------+---------+NAME
VCATNAME
---------+---------+---------+---------+---------+---------+WWV8301S
DBDSNB
WWV83ZZS
DBV8ZZZ
DSNE610I NUMBER OF ROWS DISPLAYED IS 2
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+-

By looking at this result, check, whether the hlq (or alias) DBV8ZZZ exists at all:
Data Set List Utility

No data set names found

Option ===>

blank Display data set list


V Display VTOC information

More:
P Print data set list
PV Print VTOC information

Enter one or both of the parameters below:


Dsname Level . . . DBV8ZZZ
Volume serial . .

cl

You get the message No data set names found.

pr

Ex

On the other hand, if you enter the high-level qualifier DBDSNB, you see lots of entries, so
this qualifier obviously exists. This difference points to the reason why the last
CREATE TABLESPACE statement failed: DB2 can only create data sets if the aliases for
their hlq have already been defined.

A-8

DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 2: Creating tables


Steps 1 to 12: Creating tables
NOT
NOT
NOT
NOT
NOT

NULL,
NULL,
NULL,
NULL,
NULL)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE TABLE LOCATION


(LOCID
CHAR(10)
ADDRESS
CHAR(30)
CITY
CHAR(30)
POSTAL_CODE CHAR(15)
COUNTRY
CHAR(30)
IN WWV8301D.TSLOCN;

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE TABLE DEPARTMENT
(DEPTNO
CHAR(3)
NOT NULL,
SUPERIOR_DEPTNO CHAR(3)
,
MGRNO
CHAR(6)
,
NAME
VARCHAR(50) NOT NULL)
IN WWV8301D.TSDEPT;

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

NOT NULL,
NOT NULL,
NOT NULL,
,
,
,
NOT NULL)

cl

CREATE TABLE PROJECT


(PROJNO
CHAR(6)
DEPTNO
CHAR(3)
EMPNO
CHAR(6)
STAFFING
DECIMAL(5,2)
START_DATE DATE
END_DATE
DATE
NAME
VARCHAR(50)
IN WWV8301D.TSPROJ;

Ex

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
NOT NULL,
NOT NULL)

pr

CREATE TABLE ON_PROJECT


(PROJNO
CHAR(6)
EMPNO
CHAR(6)
IN WWV8301D.TSPROJ;

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-9

Student Exercises

NOT
NOT
NOT
NOT

NULL,
NULL,
NULL,
NULL,
,
,
)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE TABLE ACTIVITY


(PROJNO
CHAR(6)
EMPNO
CHAR(6)
SEQNO
SMALLINT
CODE
SMALLINT
TIME_SPENT DECIMAL(5,2)
START_DATE DATE
END_DATE
DATE
IN WWV8301D.TSPROJ;

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE TABLE EMPLOYEE
(EMPNO
CHAR(6)
NOT NULL,
FIRST_NAME
CHAR(20)
NOT NULL,
MIDDLE_INITIAL CHAR(1)
,
SEX
CHAR(1)
NOT NULL,
BIRTHDATE
DATE
,
PHONE
CHAR(4)
,
HIRING_DATE
DATE
,
JOB
CHAR(20)
,
EDUCATION
SMALLINT
NOT NULL,
SALARY
DECIMAL(9,2)
,
BONUS
DECIMAL(9,2)
,
COMMISSION
DECIMAL(9,2)
,
DEPTNO
CHAR(3)
,
LOCID
CHAR(10)
,
LAST_NAME
VARCHAR(50)
NOT NULL,
CONSTRAINT SEX CHECK(SEX IN ('M', 'F')))
PARTITION BY (EMPNO ASC)
(PARTITION 1 ENDING AT ('000150'),
PARTITION 2 ENDING AT ('000230'),
PARTITION 3 ENDING AT ('001000'))
IN WWV8301D.TSEMPL;

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

A-10 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Steps 13 to 15: Querying the DB2 catalog tables

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT SUBSTR(NAME,1,10) AS NAME, TYPE,


SUBSTR(DBNAME,1,8) AS DBNAME, SUBSTR(TSNAME,1,8) AS TSNAME,
COLCOUNT, RECLENGTH, CHECKS, STATUS
FROM SYSIBM.SYSTABLES
WHERE CREATOR = USER
AND NAME NOT IN ('EMP')
WITH UR ;

---------+---------+---------+---------+---------+---------+---------+---------+--NAME
TYPE DBNAME
TSNAME
COLCOUNT RECLENGTH CHECKS
STATUS
---------+---------+---------+---------+---------+---------+---------+---------+---LOCATION
DEPARTMENT
PROJECT
ON_PROJECT
ACTIVITY
EMPLOYEE

T
T
T
T
T
T

WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D

TSLOCN
TSDEPT
TSPROJ
TSPROJ
TSPROJ
TSEMPL

5
4
7
2
7
15

123
74
89
20
38
160

0
0
0
0
0
1

DSNE610I NUMBER OF ROWS DISPLAYED IS 6


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

SELECT SUBSTR(NAME,1,8) AS NAME, SUBSTR(CREATOR,1,8) AS CREATOR,

SUBSTR(DBNAME,1,8) AS DBNAME, PARTITIONS, STATUS, NTABLES


FROM SYSIBM.SYSTABLESPACE
WHERE CREATOR = USER
WITH UR ;

---------+---------+---------+---------+---------+---------+---------+---------+
NAME
CREATOR
DBNAME
PARTITIONS STATUS NTABLES
---------+---------+---------+---------+---------+---------+---------+---------+
TSOUB01
TSOUB01
TSOUB01
TSOUB01

cl

TSLOCN
TSDEPT
TSEMPL
TSPROJ

WWV8301D
WWV8301D
WWV8301D
WWV8301D

0 A
1 A
3 A
0 A

1
1
1
3

pr

Ex

DSNE610I NUMBER OF ROWS DISPLAYED IS 4


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-11

Student Exercises

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT SUBSTR(NAME,1,18) AS NAME, SUBSTR(TBNAME,1,10) AS TBNAME,


COLNO, COLTYPE, LENGTH, SCALE, NULLS
FROM SYSIBM.SYSCOLUMNS
WHERE TBCREATOR = USER
AND TBNAME NOT IN ('EMP')
ORDER BY TBNAME, COLNO
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+---------+
NAME
TBNAME
COLNO COLTYPE
LENGTH
SCALE NULLS
---------+---------+---------+---------+---------+---------+---------+---------+
ACTIVITY
ACTIVITY
ACTIVITY
ACTIVITY
ACTIVITY
ACTIVITY
ACTIVITY
DEPARTMENT
DEPARTMENT
DEPARTMENT
DEPARTMENT
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
EMPLOYEE
LOCATION
LOCATION
LOCATION
LOCATION
LOCATION
ON_PROJECT
ON_PROJECT
PROJECT
PROJECT
PROJECT
PROJECT
PROJECT
PROJECT
PROJECT

pr

Ex

cl

PROJNO
EMPNO
SEQNO
CODE
TIME_SPENT
START_DATE
END_DATE
DEPTNO
SUPERIOR_DEPTNO
MGRNO
NAME
EMPNO
FIRST_NAME
MIDDLE_INITIAL
SEX
BIRTHDATE
PHONE
HIRING_DATE
JOB
EDUCATION
SALARY
BONUS
COMMISSION
DEPTNO
LOCID
LAST_NAME
LOCID
ADDRESS
CITY
POSTAL_CODE
COUNTRY
PROJNO
EMPNO
PROJNO
DEPTNO
EMPNO
STAFFING
START_DATE
END_DATE
NAME

1
2
3
4
5
6
7
1
2
3
4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
2
3
4
5
1
2
1
2
3
4
5
6
7

CHAR
CHAR
SMALLINT
SMALLINT
DECIMAL
DATE
DATE
CHAR
CHAR
CHAR
VARCHAR
CHAR
CHAR
CHAR
CHAR
DATE
CHAR
DATE
CHAR
SMALLINT
DECIMAL
DECIMAL
DECIMAL
CHAR
CHAR
VARCHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
DECIMAL
DATE
DATE
VARCHAR

6
6
2
2
5
4
4
3
3
6
50
6
20
1
1
4
4
4
20
2
9
9
9
3
10
50
10
30
30
15
30
6
6
6
3
6
5
4
4
50

0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
2
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0

N
N
N
N
Y
Y
Y
N
Y
Y
N
N
N
Y
N
Y
Y
Y
Y
N
Y
Y
Y
Y
Y
N
N
N
N
N
N
N
N
N
N
N
Y
Y
Y
N

DSNE610I NUMBER OF ROWS DISPLAYED IS 40

A-12 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Optional labs:
Step 16: Catalog information on check constraints

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+
SELECT TBOWNER, CREATOR, TBNAME, CHECKNAME, CHECKCONDITION
FROM SYSIBM.SYSCHECKS
WHERE TBOWNER = 'TSOUB01'
AND TBNAME = 'EMPLOYEE'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+
TBOWNER
CREATOR
TBNAME
CHECKNAME
CHECKCONDI
---------+---------+---------+---------+---------+---------+---------+
TSOUB01
TSOUB01
EMPLOYEE
SEX
SEX IN ('M', 'F')
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
---------+---------+---------+---------+---------+---------+---------+
---------+---------+---------+---------+---------+---------+---------+
SELECT TBOWNER, TBNAME, CHECKNAME, COLNAME
FROM SYSIBM.SYSCHECKDEP
WHERE TBOWNER = 'TSOUB01'
AND TBNAME = 'EMPLOYEE'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+
TBOWNER
TBNAME
CHECKNAME
COLNAME
---------+---------+---------+---------+---------+---------+---------+
TSOUB01
EMPLOYEE
SEX
SEX
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
---------+---------+---------+---------+---------+---------+---------+

Step 17: Catalog information on partition limit keys

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
SELECT PARTITION, TSNAME, DBNAME, LIMITKEY, LIMITKEY_INTERNAL
FROM SYSIBM.SYSTABLEPART P
WHERE DBNAME = 'WWV8301D' AND TSNAME = 'TSEMPL'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+---------+
PARTITION TSNAME
DBNAME
LIMITKEY
LIMITKEY_INTERNAL
---------+---------+---------+---------+---------+---------+---------+---------+
1 TSEMPL
WWV8301D
'000150'
000150
2 TSEMPL
WWV8301D
'000230'
000230
3 TSEMPL
WWV8301D
'001000'
001000
DSNE610I NUMBER OF ROWS DISPLAYED IS 3
---------+---------+---------+---------+---------+---------+---------+---------+

Remark:
Since table-controlled partitioning is used, LIMITKEY_INTERNAL is filled with values.
Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-13

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

A-14 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 3: Creating and using views


Steps 1 to 2: Create view V1

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE VIEW V1
AS SELECT EMPNO AS SERIAL_NUMBER, SALARY,
FIRST_NAME, LAST_NAME, SEX, EDUCATION
FROM
EMP
WHERE SALARY < 20000

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-15

Student Exercises

Step 3: Select from V1 and EMP

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT * FROM V1;


---------+---------+---------+---------+---------+---------+---------+---------+
SERIAL_NUMBER
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000210
18270.00 WILLIAM
JONES
000250
19180.00 DANIEL
SMITH
000260
17250.00 SYBIL
JOHNSON
000290
15340.00 JOHN
PARKER
000300
17750.00 PHILIP
SMITH
000310
15900.00 MAUDE
SETRIGHT
000320
19950.00 RAMLAL
MEHTA
DSNE610I NUMBER OF ROWS DISPLAYED IS 7

SELECT EMPNO, SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION,


MIDDLE_INITIAL, BIRTHDATE, PHONE, HIRING_DATE,
JOB, BONUS, COMMISSION, DEPTNO, LOCID
FROM EMP
---------+---------+---------+---------+---------+---------+---------+---------+
EMPNO
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000010
52750.00 CHRISTINE
HAAS
000020
41250.00 MICHAEL
THOMPSON
... 15 lines removed .................................
BROWN
JONES
LUTZ
JEFFERSON
MARINO
SMITH
JOHNSON
PEREZ
SCHNEIDER
PARKER
SMITH
SETRIGHT
MEHTA
LEE
GOUNOT

pr

Ex

cl

000200
27740.00 DAVID
000210
18270.00 WILLIAM
000220
29840.00 JENNIFER
000230
22180.00 JAMES
000240
28760.00 SALVATORE
000250
19180.00 DANIEL
000260
17250.00 SYBIL
000270
27380.00 MARIA
000280
26250.00 ETHEL
000290
15340.00 JOHN
000300
17750.00 PHILIP
000310
15900.00 MAUDE
000320
19950.00 RAMLAL
000330
25370.00 WING
000340
23840.00 JASON
DSNE610I NUMBER OF ROWS DISPLAYED IS 32

A-16 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Steps 4 to 5: INSERT using V1


INSERT INTO V1
(SERIAL_NUMBER,
SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION)
VALUES('000350', 15000, 'GEORGE', 'HARRISON','M', 22);

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
INSERT INTO V1
(SERIAL_NUMBER,
SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION)
VALUES('000360', 50000, 'RINGO', 'STARR','M', 22)

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

pr

Ex

cl

Rows inserted through view V1 do not have to conform to the definition of V1.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-17

Student Exercises

Step 6: Select from V1 and EMP

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT * FROM V1;


---------+---------+---------+---------+---------+---------+---------+---------+
SERIAL_NUMBER
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000210
18270.00 WILLIAM
JONES
000250
19180.00 DANIEL
SMITH
000260
17250.00 SYBIL
JOHNSON
000290
15340.00 JOHN
PARKER
000300
17750.00 PHILIP
SMITH
000310
15900.00 MAUDE
SETRIGHT
000320
19950.00 RAMLAL
MEHTA
000350
15000.00 GEORGE
HARRISON
DSNE610I NUMBER OF ROWS DISPLAYED IS 8

SELECT EMPNO, SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION,


MIDDLE_INITIAL, BIRTHDATE, PHONE, HIRING_DATE,
JOB, BONUS, COMMISSION, DEPTNO, LOCID
FROM EMP
---------+---------+---------+---------+---------+---------+---------+---------+
EMPNO
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000010
52750.00 CHRISTINE
HAAS
000020
41250.00 MICHAEL
THOMPSON
... 15 lines removed .................................
BROWN
JONES
LUTZ
JEFFERSON
MARINO
SMITH
JOHNSON
PEREZ
SCHNEIDER
PARKER
SMITH
SETRIGHT
MEHTA
LEE
GOUNOT
HARRISON
STARR

pr

Ex

cl

000200
27740.00 DAVID
000210
18270.00 WILLIAM
000220
29840.00 JENNIFER
000230
22180.00 JAMES
000240
28760.00 SALVATORE
000250
19180.00 DANIEL
000260
17250.00 SYBIL
000270
27380.00 MARIA
000280
26250.00 ETHEL
000290
15340.00 JOHN
000300
17750.00 PHILIP
000310
15900.00 MAUDE
000320
19950.00 RAMLAL
000330
25370.00 WING
000340
23840.00 JASON
000350
15000.00 GEORGE
000360
50000.00 RINGO
DSNE610I NUMBER OF ROWS DISPLAYED IS 34

A-18 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 7: DELETE using V1


DELETE FROM V1
WHERE SERIAL_NUMBER = '000350'

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

The row with a serial number of 000350 satisfies the definition of view V1.

Step 8: DELETE using V1

DELETE FROM V1
WHERE SERIAL_NUMBER = '000360'

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

pr

Ex

cl

The row with a serial number of 000360 does not satisfy the definition of view V1.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-19

Student Exercises

Step 9: Select from V1 and EMP

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT * FROM V1;


---------+---------+---------+---------+---------+---------+---------+---------+
SERIAL_NUMBER
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000210
18270.00 WILLIAM
JONES
000250
19180.00 DANIEL
SMITH
000260
17250.00 SYBIL
JOHNSON
000290
15340.00 JOHN
PARKER
000300
17750.00 PHILIP
SMITH
000310
15900.00 MAUDE
SETRIGHT
000320
19950.00 RAMLAL
MEHTA
DSNE610I NUMBER OF ROWS DISPLAYED IS 7

SELECT EMPNO, SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION,


MIDDLE_INITIAL, BIRTHDATE, PHONE, HIRING_DATE,
JOB, BONUS, COMMISSION, DEPTNO, LOCID
FROM EMP
---------+---------+---------+---------+---------+---------+---------+---------+
EMPNO
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000010
52750.00 CHRISTINE
HAAS
000020
41250.00 MICHAEL
THOMPSON
... 15 lines removed .................................
BROWN
JONES
LUTZ
JEFFERSON
MARINO
SMITH
JOHNSON
PEREZ
SCHNEIDER
PARKER
SMITH
SETRIGHT
MEHTA
LEE
GOUNOT
STARR

pr

Ex

cl

000200
27740.00 DAVID
000210
18270.00 WILLIAM
000220
29840.00 JENNIFER
000230
22180.00 JAMES
000240
28760.00 SALVATORE
000250
19180.00 DANIEL
000260
17250.00 SYBIL
000270
27380.00 MARIA
000280
26250.00 ETHEL
000290
15340.00 JOHN
000300
17750.00 PHILIP
000310
15900.00 MAUDE
000320
19950.00 RAMLAL
000330
25370.00 WING
000340
23840.00 JASON
000360
50000.00 RINGO
DSNE610I NUMBER OF ROWS DISPLAYED IS 33

A-20 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 10: UPDATE using V1


UPDATE V1
SET SALARY = SALARY + 5000
WHERE SERIAL_NUMBER = '000260'

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

The row with a serial number of 000260 satisfies the definition of view V1.

Step 11: UPDATE using V1

UPDATE V1
SET SALARY = SALARY - 5000
WHERE SERIAL_NUMBER = '000260'

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

pr

Ex

cl

The row with a serial number of 000260 does not satisfy the definition of view V1.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-21

Student Exercises

Step 12: Select from V1 and EMP

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT * FROM V1;


---------+---------+---------+---------+---------+---------+---------+---------+
SERIAL_NUMBER
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000210
18270.00 WILLIAM
JONES
000250
19180.00 DANIEL
SMITH
000290
15340.00 JOHN
PARKER
000300
17750.00 PHILIP
SMITH
000310
15900.00 MAUDE
SETRIGHT
000320
19950.00 RAMLAL
MEHTA
DSNE610I NUMBER OF ROWS DISPLAYED IS 6

SELECT EMPNO, SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION,


MIDDLE_INITIAL, BIRTHDATE, PHONE, HIRING_DATE,
JOB, BONUS, COMMISSION, DEPTNO, LOCID
FROM EMP
---------+---------+---------+---------+---------+---------+---------+---------+
EMPNO
SALARY FIRST_NAME
LAST_NAME
---------+---------+---------+---------+---------+---------+---------+---------+
000010
52750.00 CHRISTINE
HAAS
000020
41250.00 MICHAEL
THOMPSON
... 15 lines removed .................................
BROWN
JONES
LUTZ
JEFFERSON
MARINO
SMITH
JOHNSON
PEREZ
SCHNEIDER
PARKER
SMITH
SETRIGHT
MEHTA
LEE
GOUNOT
STARR

pr

Ex

cl

000200
27740.00 DAVID
000210
18270.00 WILLIAM
000220
29840.00 JENNIFER
000230
22180.00 JAMES
000240
28760.00 SALVATORE
000250
19180.00 DANIEL
000260
22250.00 SYBIL
000270
27380.00 MARIA
000280
26250.00 ETHEL
000290
15340.00 JOHN
000300
17750.00 PHILIP
000310
15900.00 MAUDE
000320
19950.00 RAMLAL
000330
25370.00 WING
000340
23840.00 JASON
000360
50000.00 RINGO
DSNE610I NUMBER OF ROWS DISPLAYED IS 33

A-22 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Steps 13 to 14: Create view V2

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE VIEW V2
AS SELECT EMPNO AS SERIAL_NUMBER, SALARY,
FIRST_NAME, LAST_NAME, SEX, EDUCATION
FROM
EMP
WHERE SALARY < 20000
WITH CHECK OPTION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Step 15: INSERT using V2

INSERT INTO V2
(SERIAL_NUMBER,
SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION)
VALUES('000370', 15000, 'LIAM', 'GALLAGHER','M', 22);

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
INSERT INTO V2
(SERIAL_NUMBER,
SALARY, FIRST_NAME, LAST_NAME, SEX, EDUCATION)
VALUES('000380', 50000, 'NOEL', 'GALLAGHER','M', 22)

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -161, ERROR: THE INSERT OR UPDATE IS NOT ALLOWED BECAUSE A
RESULTING ROW DOES NOT SATISFY THE VIEW DEFINITION
DSNT418I SQLSTATE
= 44000 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXRSVW SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= -160 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'FFFFFF60' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-23

Student Exercises

Step 16: UPDATE using V2


UPDATE V2
SET SALARY = SALARY + 0100
WHERE SERIAL_NUMBER = '000290';

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
UPDATE V2
SET SALARY = SALARY + 5000
WHERE SERIAL_NUMBER = '000290'

---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -161, ERROR: THE INSERT OR UPDATE IS NOT ALLOWED BECAUSE A
RESULTING ROW DOES NOT SATISFY THE VIEW DEFINITION
DSNT418I SQLSTATE
= 44000 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXRSVW SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= -160 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'FFFFFF60' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Steps 17 to 18: Create view V3

CREATE VIEW V3
AS SELECT EMPNO AS SERIAL_NUMBER, SALARY,
FIRST_NAME, LAST_NAME, SEX
FROM
EMP
WHERE SALARY < 20000

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

A-24 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 19: INSERT using V3


INSERT INTO V3
(SERIAL_NUMBER,
SALARY, FIRST_NAME, LAST_NAME, SEX)
VALUES('000380', 50000, 'NOEL', 'GALLAGHER','M')

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -551, ERROR: TSOUB01 DOES NOT HAVE THE PRIVILEGE TO PERFORM
OPERATION INSERT ON OBJECT TSOUB01.V3
DSNT418I SQLSTATE
= 42501 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXOIN SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= -600 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'FFFFFDA8' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

The insert fails because the definition of view V3 does not include non-nullable column
EDUCATION.

Step 20: Querying the DB2 catalog table

SELECT SUBSTR(TCREATOR,1,8) AS TCREATOR,


SUBSTR(TTNAME,1,8) AS TTNAME,
SELECTAUTH, DELETEAUTH, INSERTAUTH, UPDATEAUTH
FROM
SYSIBM.SYSTABAUTH
WHERE TCREATOR = USER
AND TTNAME LIKE 'V%'
---------+---------+---------+---------+---------+---------+---------+---------+
TCREATOR TTNAME
SELECTAUTH DELETEAUTH INSERTAUTH UPDATEAUTH
---------+---------+---------+---------+---------+---------+---------+---------+
V1
V2
V3

G
G
G

cl

TSOUB01
TSOUB01
TSOUB01

G
G
G

G
G

G
G
G

Ex

DSNE610I NUMBER OF ROWS DISPLAYED IS 3


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

pr

The owner of view V3 does not have INSERT privilege on V3 because the definition of V3
does not include non-nullable column EDUCATION.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-25

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

A-26 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 4: Creating indexes


Step 1: Create four indexes (on LOCATION and DEPARTMENT)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE UNIQUE INDEX IXLOCN1


ON LOCATION(LOCID);
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE UNIQUE INDEX IXDEPT1
ON DEPARTMENT(DEPTNO)
CLUSTER;

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE INDEX IXDEPT2
ON DEPARTMENT(MGRNO);

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE INDEX IXDEPT3
ON DEPARTMENT(SUPERIOR_DEPTNO);

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-27

Student Exercises

Step 2: Create the remaining 10 indexes - with specifications for


IXEMPL1 and IXONPR1 - via DSNTEP2

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

***************************** Top of Data ******************************


//DSNTEP2 EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT)
//STEPLIB DD DSN=DBDSNB.DB2A10.SDSNLOAD,DISP=SHR
//DBRMLIB DD DSN=DBDSNB.DB2A10.DBRMLIB.DATA,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DSNB)
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP10) LIB('DBDSNB.DB2A10.RUNLIB.LOAD') PARMS('/ALIGN(MID)')
END
//SYSIN
DD *
CREATE UNIQUE INDEX IXEMPL1
ON EMPLOYEE(EMPNO)
PARTITIONED
CLUSTER;
CREATE INDEX IXEMPL2
ON EMPLOYEE(DEPTNO);
CREATE INDEX IXEMPL3
ON EMPLOYEE(LOCID);

CREATE UNIQUE INDEX IXPROJ1


ON PROJECT(PROJNO);
CREATE INDEX IXPROJ2
ON PROJECT(DEPTNO);

cl

CREATE INDEX IXPROJ3


ON PROJECT(EMPNO)
CLUSTER;

CREATE UNIQUE INDEX IXONPR1


ON ON_PROJECT(PROJNO, EMPNO);

Ex

CREATE INDEX IXONPR2


ON ON_PROJECT(EMPNO)
CLUSTER;

pr

CREATE UNIQUE INDEX IXACTY1


ON ACTIVITY(PROJNO, EMPNO, SEQNO);

CREATE INDEX IXACTY2


ON ACTIVITY(EMPNO);
**************************** Bottom of Data ****************************

A-28 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Partial DSNTEP2 job output:

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

********************************* TOP OF DATA **********************************


1
1PAGE
1
***INPUT STATEMENT:
CREATE UNIQUE INDEX IXEMPL1
ON EMPLOYEE(EMPNO)
PARTITIONED
CLUSTER;
RESULT OF SQL STATEMENT:
DSNT400I SQLCODE = 000, SUCCESSFUL EXECUTION
DSNT418I SQLSTATE
= 00000 SQLSTATE RETURN CODE
DSNT416I SQLERRD
= 0 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'00000000' X'00000000' X'00000000' X'FFFFFFFF' ....
INFORMATION
CREATE
SUCCESSFUL
1PAGE
1
***INPUT STATEMENT:
CREATE INDEX IXEMPL2
ON EMPLOYEE(DEPTNO);
RESULT OF SQL STATEMENT:
DSNT400I SQLCODE = 000, SUCCESSFUL EXECUTION
DSNT418I SQLSTATE
= 00000 SQLSTATE RETURN CODE
DSNT416I SQLERRD
= 0 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'00000000' X'00000000' X'00000000' X'FFFFFFFF' ....
INFORMATION
CREATE
SUCCESSFUL
............. etc.........
******************************** BOTTOM OF DATA ********************************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-29

Student Exercises

Steps 3 to 5: Querying the DB2 catalog tables

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT SUBSTR(NAME,1,7) AS NAME,


SUBSTR(TBNAME,1,10) AS TBNAME,
SUBSTR(DBNAME,1,8) AS DBNAME,
UNIQUERULE, CLUSTERING, INDEXSPACE, BPOOL, PIECESIZE
FROM SYSIBM.SYSINDEXES
WHERE CREATOR = USER
AND NAME NOT IN ('IXLAB3')
ORDER BY NAME
WITH UR ;

---------+---------+---------+---------+---------+---------+---------+---------+---------+
NAME
TBNAME
DBNAME
UNIQUERULE CLUSTERING INDEXSPACE BPOOL
PIECESIZE
---------+---------+---------+---------+---------+---------+---------+---------+---------+
IXACTY1
IXACTY2
IXDEPT1
IXDEPT2
IXDEPT3
IXEMPL1
IXEMPL2
IXEMPL3
IXLOCN1
IXONPR1
IXONPR2
IXPROJ1
IXPROJ2
IXPROJ3

ACTIVITY
ACTIVITY
DEPARTMENT
DEPARTMENT
DEPARTMENT
EMPLOYEE
EMPLOYEE
EMPLOYEE
LOCATION
ON_PROJECT
ON_PROJECT
PROJECT
PROJECT
PROJECT

WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D
WWV8301D

U
D
U
D
D
U
D
D
U
U
D
U
D
D

N
N
Y
N
N
Y
N
N
N
N
Y
N
N
Y

IXACTY1
IXACTY2
IXDEPT1
IXDEPT2
IXDEPT3
IXEMPL1
IXEMPL2
IXEMPL3
IXLOCN1
IXONPR1
IXONPR2
IXPROJ1
IXPROJ2
IXPROJ3

BP2
BP2
BP2
BP2
BP2
BP2
BP2
BP2
BP2
BP2
BP2
BP2
BP2
BP2

2097152
2097152
4194304
4194304
4194304
0
4194304
4194304
2097152
2097152
2097152
2097152
2097152
2097152

pr

Ex

cl

DSNE610I NUMBER OF ROWS DISPLAYED IS 14


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+---------+

A-30 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

---------+---------+---------+---------+---------+---------+---------+
SELECT SUBSTR(IXNAME,1,8) AS IXNAME,
PARTITION,
SUBSTR(CHAR(PQTY),1,4) AS PQTY,
SUBSTR(STORNAME,1,8) AS STORNAME,
SUBSTR(VCATNAME,1,8) AS VCATNAME,
SUBSTR(LIMITKEY,1,6) AS LIMITKEY,
FREEPAGE, PCTFREE
FROM SYSIBM.SYSINDEXPART IP
WHERE IXCREATOR = USER
AND IXNAME NOT IN ('IXLAB3')
ORDER BY IXNAME, PARTITION
WITH UR ;

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

---------+---------+---------+---------+---------+---------+---------+---------+
IXNAME
PARTITION PQTY STORNAME
VCATNAME
LIMITKEY FREEPAGE PCTFREE
---------+---------+---------+---------+---------+---------+---------+---------+
IXACTY1
0
-1
WWV8301S
DBDSNB
......
0
10
IXACTY2
0
-1
WWV8301S
DBDSNB
......
0
10
IXDEPT1
0
-1
WWV8301S
DBDSNB
......
0
10
IXDEPT2
0
-1
WWV8301S
DBDSNB
......
0
10
IXDEPT3
0
-1
WWV8301S
DBDSNB
......
0
10
IXEMPL1
1
-1
WWV8301S
DBDSNB
......
0
10
IXEMPL1
2
-1
WWV8301S
DBDSNB
......
0
10
IXEMPL1
3
-1
WWV8301S
DBDSNB
......
0
10
IXEMPL2
0
-1
WWV8301S
DBDSNB
......
0
10
IXEMPL3
0
-1
WWV8301S
DBDSNB
......
0
10
IXLOCN1
0
-1
WWV8301S
DBDSNB
......
0
10
IXONPR1
0
-1
WWV8301S
DBDSNB
......
0
10
IXONPR2
0
-1
WWV8301S
DBDSNB
......
0
10
IXPROJ1
0
-1
WWV8301S
DBDSNB
......
0
10
IXPROJ2
0
-1
WWV8301S
DBDSNB
......
0
10
IXPROJ3
0
-1
WWV8301S
DBDSNB
......
0
10
DSNE610I NUMBER OF ROWS DISPLAYED IS 16
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

cl

Remarks:

Ex

LIMITKEY is x20, a Unicode blank; the column is defined as varchar(512) for bit data.
Therefore the correct expression would be: SUBSTR(CAST(CAST(LIMITKEY AS
VARCHAR(512) CCSID 1208) AS VARCHAR(512) CCSID EBCDIC),1,4) AS LIMITKEY,
which would eliminate the dotted output column. Similarly, other columns, like IXNAME,
should be retrieved via SUBSTRING(IXNAME,1,8,CODEUNITS16) AS IXNAME.

pr

PQTY = -1 indicates that no value has been specified for the primary quantity.

The actual amount of space allocated depends on the IXQTY DSNZPARM value (one
cylinder if IXQTY=0.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-31

Student Exercises

SELECT SUBSTR(IXNAME,1,7) AS IXNAME, SUBSTR(COLNAME,1,18) AS COLNAME,


COLSEQ, COLNO, ORDERING
FROM SYSIBM.SYSKEYS
WHERE IXCREATOR = USER
AND IXNAME NOT IN ('IXLAB3')
ORDER BY IXNAME, COLSEQ
WITH UR ;

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
IXNAME
COLNAME
COLSEQ
COLNO ORDERING
---------+---------+---------+---------+---------+---------+---------+---------+
IXACTY1
IXACTY1
IXACTY1
IXACTY2
IXDEPT1
IXDEPT2
IXDEPT3
IXEMPL1
IXEMPL2
IXEMPL3
IXLOCN1
IXONPR1
IXONPR1
IXONPR2
IXPROJ1
IXPROJ2
IXPROJ3

PROJNO
EMPNO
SEQNO
EMPNO
DEPTNO
MGRNO
SUPERIOR_DEPTNO
EMPNO
DEPTNO
LOCID
LOCID
PROJNO
EMPNO
EMPNO
PROJNO
DEPTNO
EMPNO

1
2
3
1
1
1
1
1
1
1
1
1
2
1
1
1
1

1
2
3
2
1
3
2
1
13
14
1
1
2
2
1
2
3

A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A

pr

Ex

cl

DSNE610I NUMBER OF ROWS DISPLAYED IS 17


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

A-32 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 6: -DISPLAY DATABASE


DB2 COMMANDS

SSID: DSNB

===>
Position cursor on the command line you want to execute and press ENTER

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Cmd 1 ===> -DISPLAY DB(WWV8301D)


Cmd 2 ===>
Cmd 3 ===>
...>
Cmd 4 ===>
...>
Cmd 5 ===>
...>
...>
Cmd 6 ===>
...>
...>
Cmd 7 ===>
DSNT360I -DSNB ***********************************
DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV8301D STATUS = RW
DBD LENGTH = 16142
DSNT397I -DSNB
NAME
TYPE PART STATUS
PHYERRLO PHYERRHI CATALOG PIECE
-------- ---- ----- ----------------- -------- -------- -------- ----TSDEPT
TS
0001 RW
TSDEPT
TS
RW
TSEMPL
TS
0001 RW
-THRU
0003
TSEMPL
TS
RW
TSLOCN
TS
RW
TSPROJ
TS
RW
IXACTY1 IX
RW
IXACTY2 IX
RW
IXDEPT1 IX
L0001 RW
IXDEPT1 IX
L*
RW
IXDEPT2 IX
L0001 RW
IXDEPT2 IX
L*
RW
IXDEPT3 IX
L0001 RW
IXDEPT3 IX
L*
RW
IXEMPL1 IX
0001 RW
-THRU
0003
IXEMPL1 IX
RW
IXEMPL2 IX
L0001 RW
-THRU
0003
IXEMPL2 IX
L*
RW
IXEMPL3 IX
L0001 RW
-THRU
0003
IXEMPL3 IX
L*
RW
IXLOCN1 IX
RW
IXONPR1 IX
RW
Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-33

Student Exercises

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

IXONPR2 IX
RW
IXPROJ1 IX
RW
IXPROJ2 IX
RW
IXPROJ3 IX
RW
******* DISPLAY OF DATABASE WWV8301D ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
***

A-34 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 7: VSAM clusters


DSLIST - Data Sets Matching DBDSNB.DSNDB*.WWV8301D.**
Command ===>

Row 1 of 44
Scroll ===> PAGE

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Command - Enter "/" to select action


Message
Volume
------------------------------------------------------------------------------DBDSNB.DSNBBC.WWV8301D.IXACTY1.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXACTY2.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXDEPT1.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXDEPT2.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXDEPT3.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXEMPL1.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXEMPL1.I0001.A002
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXEMPL1.I0001.A003
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXEMPL2.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXEMPL3.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXLOCN1.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXONPR1.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXONPR2.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXPROJ1.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXPROJ2.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.IXPROJ3.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSDEPT.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSEMPL.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSEMPL.I0001.A002
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSEMPL.I0001.A003
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSLOCN.I0001.A001
*VSAM*
DBDSNB.DSNBBC.WWV8301D.TSPROJ.I0001.A001
*VSAM*
DBDSNB.DSNBBD.WWV8301D.IXACTY1.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXACTY2.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXDEPT1.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXDEPT2.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXDEPT3.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXEMPL1.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXEMPL1.I0001.A002
SMS012
DBDSNB.DSNBBD.WWV8301D.IXEMPL1.I0001.A003
SMS012
DBDSNB.DSNBBD.WWV8301D.IXEMPL2.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXEMPL3.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXLOCN1.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXONPR1.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXONPR2.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXPROJ1.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXPROJ2.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.IXPROJ3.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.TSDEPT.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.TSEMPL.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.TSEMPL.I0001.A002
SMS012
DBDSNB.DSNBBD.WWV8301D.TSEMPL.I0001.A003
SMS012
DBDSNB.DSNBBD.WWV8301D.TSLOCN.I0001.A001
SMS012
DBDSNB.DSNBBD.WWV8301D.TSPROJ.I0001.A001
SMS012
***************************** End of Data Set list ****************************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-35

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

A-36 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 5: Creating referential structures


Step 1: Defining primary keys

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

ALTER TABLE LOCATION


ADD CONSTRAINT
LOCID
PRIMARY KEY (LOCID);
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
ALTER TABLE DEPARTMENT
ADD CONSTRAINT
DEPTNO
PRIMARY KEY (DEPTNO);
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
ALTER TABLE EMPLOYEE
ADD CONSTRAINT
EMPNO
PRIMARY KEY (EMPNO);
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
ALTER TABLE PROJECT
ADD CONSTRAINT
PROJNO
PRIMARY KEY (PROJNO);
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Ex

cl

ALTER TABLE ON_PROJECT


ADD CONSTRAINT
PROJNO_EMPNO
PRIMARY KEY (PROJNO,EMPNO);
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

pr

ALTER TABLE ACTIVITY


ADD CONSTRAINT
PROJNO_EMPNO_SEQNO
PRIMARY KEY (PROJNO,EMPNO,SEQNO);
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-37

Student Exercises

Step 2: Defining foreign keys and delete rules on DEPARTMENT

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

ALTER TABLE DEPARTMENT


ADD CONSTRAINT DD
FOREIGN KEY (SUPERIOR_DEPTNO)
REFERENCES DEPARTMENT
ON DELETE NO ACTION;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
ALTER TABLE DEPARTMENT
ADD CONSTRAINT ED
FOREIGN KEY (MGRNO)
REFERENCES EMPLOYEE
ON DELETE SET NULL;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Step 3: Defining foreign keys on the remaining tables

ALTER TABLE EMPLOYEE


ADD CONSTRAINT LE
FOREIGN KEY (LOCID)
REFERENCES LOCATION
ON DELETE NO ACTION;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

pr

Ex

cl

ALTER TABLE EMPLOYEE


ADD CONSTRAINT DE
FOREIGN KEY (DEPTNO)
REFERENCES DEPARTMENT
ON DELETE SET NULL;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

A-38 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

ALTER TABLE PROJECT


ADD CONSTRAINT DP
FOREIGN KEY (DEPTNO)
REFERENCES DEPARTMENT
ON DELETE NO ACTION;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

ALTER TABLE PROJECT


ADD CONSTRAINT EP
FOREIGN KEY (EMPNO)
REFERENCES EMPLOYEE
ON DELETE NO ACTION;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
ALTER TABLE ON_PROJECT
ADD CONSTRAINT EO
FOREIGN KEY (EMPNO)
REFERENCES EMPLOYEE
ON DELETE CASCADE;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

cl

ALTER TABLE ON_PROJECT


ADD CONSTRAINT PO
FOREIGN KEY (PROJNO)
REFERENCES PROJECT
ON DELETE CASCADE;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

pr

Ex

ALTER TABLE ACTIVITY


ADD CONSTRAINT OA
FOREIGN KEY (PROJNO,EMPNO)
REFERENCES ON_PROJECT
ON DELETE CASCADE;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-39

Student Exercises

Step 4: Querying the DB2 catalog tables

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT SUBSTR(CONSTNAME,1,20) AS CONSTNAME,


SUBSTR(TBNAME,1,10) AS TBNAME, TYPE,
SUBSTR(IXNAME,1,7) AS IXAME, COLCOUNT
FROM SYSIBM.SYSTABCONST
WHERE TBCREATOR = USER
ORDER BY CREATEDTS
WITH UR ;

---------+---------+---------+---------+---------+---------+---------+---------+
CONSTNAME
TBNAME
TYPE IXNAME
COLCOUNT
---------+---------+---------+---------+---------+---------+---------+---------+
LOCID
DEPTNO
EMPNO
PROJNO
PROJNO_EMPNO
PROJNO_EMPNO_SEQNO

LOCATION
DEPARTMENT
EMPLOYEE
PROJECT
ON_PROJECT
ACTIVITY

P
P
P
P
P
P

IXLOCN1
IXDEPT1
IXEMPL1
IXPROJ1
IXONPR1
IXACTY1

1
1
1
1
2
3

DSNE610I NUMBER OF ROWS DISPLAYED IS 6


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

SELECT SUBSTR(CONSTNAME,1,20) AS CONSTNAME,


SUBSTR(TBNAME,1,10) AS TBNAME,
SUBSTR(COLNAME,1,10) AS COLNAME,
COLSEQ, COLNO
FROM SYSIBM.SYSKEYCOLUSE
WHERE TBCREATOR = USER
ORDER BY CONSTNAME, COLSEQ
WITH UR ;

cl

---------+---------+---------+---------+---------+---------+---------+---------+
CONSTNAME
TBNAME
COLNAME
COLSEQ
COLNO
---------+---------+---------+---------+---------+---------+---------+---------+
DEPARTMENT
EMPLOYEE
LOCATION
PROJECT
ON_PROJECT
ON_PROJECT
ACTIVITY
ACTIVITY
ACTIVITY

pr

Ex

DEPTNO
EMPNO
LOCID
PROJNO
PROJNO_EMPNO
PROJNO_EMPNO
PROJNO_EMPNO_SEQNO
PROJNO_EMPNO_SEQNO
PROJNO_EMPNO_SEQNO

DEPTNO
EMPNO
LOCID
PROJNO
PROJNO
EMPNO
PROJNO
EMPNO
SEQNO

1
1
1
1
1
2
1
2
3

1
1
1
1
1
2
1
2
3

DSNE610I NUMBER OF ROWS DISPLAYED IS 9


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

A-40 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

SELECT SUBSTR(REFTBNAME,1,10) AS REFTBNAME,


SUBSTR(TBNAME,1,10) AS TBNAME,
SUBSTR(RELNAME,1,20) AS RELNAME,
COLCOUNT, DELETERULE
FROM SYSIBM.SYSRELS
WHERE CREATOR = USER
ORDER BY REFTBNAME, TBNAME
WITH UR ;

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

---------+---------+---------+---------+---------+---------+---------+---------+
REFTBNAME
TBNAME
RELNAME
COLCOUNT DELETERULE
---------+---------+---------+---------+---------+---------+---------+---------+
DEPARTMENT
DEPARTMENT
DEPARTMENT
EMPLOYEE
EMPLOYEE
EMPLOYEE
LOCATION
ON_PROJECT
PROJECT

DEPARTMENT
EMPLOYEE
PROJECT
DEPARTMENT
ON_PROJECT
PROJECT
EMPLOYEE
ACTIVITY
ON_PROJECT

DD
DE
DP
ED
EO
EP
LE
OA
PO

1
1
1
1
1
1
1
2
1

A
N
A
N
C
A
A
C
C

DSNE610I NUMBER OF ROWS DISPLAYED IS 9


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

Step 5 (optional): Querying catalog table SYSIBM.SYSFOREIGNKEYS

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
SELECT *
FROM SYSIBM.SYSFOREIGNKEYS
WHERE CREATOR = USER
WITH UR ;
;
---------+---------+---------+---------+---------+---------+---------+---------+---------+
CREATOR
TBNAME
RELNAME
COLNAME
COLNO COLSEQ
IBMREQD
---------+---------+---------+---------+---------+---------+---------+---------+---------+
TSOUB01
DEPARTMENT
DD
SUPERIOR_DEPTN
2
1
N
TSOUB01
DEPARTMENT
ED
MGRNO
3
1
N
TSOUB01
EMPLOYEE
LE
LOCID
14
1
N
TSOUB01
EMPLOYEE
DE
DEPTNO
13
1
N
TSOUB01
PROJECT
DP
DEPTNO
2
1
N
TSOUB01
PROJECT
EP
EMPNO
3
1
N
TSOUB01
ON_PROJECT
EO
EMPNO
2
1
N
TSOUB01
ON_PROJECT
PO
PROJNO
1
1
N
TSOUB01
ACTIVITY
OA
PROJNO
1
1
N
TSOUB01
ACTIVITY
OA
EMPNO
2
2
N
DSNE610I NUMBER OF ROWS DISPLAYED IS 10
DSNE612I DATA FOR COLUMN HEADER COLNAME COLUMN NUMBER 4 WAS TRUNCATED
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-41

Student Exercises

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

10 rows for 9 relationships, because the foreign key on ACTIVITY is defined on 2 columns.

A-42 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 6: Loading and unloading tables


Overall remark on this lab:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Some input records are deliberately not correct so that you see the resulting error
messages and learn how you can technically react. In reality, you may react differently:
neither ignore that some records could not be loaded, nor delete loaded records because
of orphaned foreign key values, if you were not told to do exactly that. Instead, you would,
for example:
1. Determine the reasons
2. Reset the database objects to the previous state
3. Ask for revised, error-free input.

Step 1 - Prolog: The LOCATION data you load:

TSOUB01.CV83.TSLOCN.DATA
===>
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+--***************************** Top of Data ************************************
US95141-B4555 BAILEY AVENUE
SAN JOSE
CA 95141
US95141-C2555 BAILEY AVENUE
SAN JOSE
CA 95141
US95193-505600 COTTLE ROAD
SAN JOSE
CA 95193
DE71083-01AM FICHTENBERG 1
HERRENBERG
D-71083
**************************** Bottom of Data **********************************

...
...
...
...
...
...
...

Step 1a: Utility control statement for loading the LOCATION table
TSOUB01.CV83.CNTL(L6TSLOCN)

pr

Ex

cl

***************************** Top of Data *********


LOAD DATA
INTO TABLE LOCATION
( LOCID
POSITION ( 1: 10) CHAR(10),
ADDRESS
POSITION (11: 40) CHAR(30),
CITY
POSITION (41: 70) CHAR(30),
POSTAL_CODE POSITION (71: 85) CHAR(15),
COUNTRY
POSITION (86:115) CHAR(30) )
**************************** Bottom of Data *******

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-43

Student Exercises

Step 1b: Job for loading the LOCATION table, generated via DB2I
TSOUB01.DSNULOA.CNTL

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

//TSOUB011 JOB 1CV83G26,'TSOUB01 JOB


',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=TSOUB01,REGION=0M
//*
//*
//UTIL EXEC DSNBUPRC,SYSTEM=DSNB,UID='TSOUB01',UTPROC=''
//*
//**********************************************
//*
//* GENERATING JCL FOR THE LOAD UTILITY
//* DATE: 08/26/11
TIME: 07:52:39
//*
//**********************************************
//*
//DSNUPROC.SORTWK01 DD DSN=TSOUB01.SORTWK01,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTWK02 DD DSN=TSOUB01.SORTWK02,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTWK03 DD DSN=TSOUB01.SORTWK03,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTWK04 DD DSN=TSOUB01.SORTWK04,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSREC DD DSN=TSOUB01.CV83.TSLOCN.DATA,
//
DISP=OLD
//DSNUPROC.SYSDISC DD DSN=TSOUB01.CV83.TSLOCN.DISCARD,
//
DISP=(MOD,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSUT1 DD DSN=TSOUB01.SYSUT1,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTOUT DD DSN=TSOUB01.SORTOUT,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSERR DD DSN=TSOUB01.SYSERR,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSMAP DD DSN=TSOUB01.SYSMAP,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSIN
DD *

A-44 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

LOAD DATA
INTO TABLE LOCATION
( LOCID
POSITION ( 1: 10) CHAR(10),
ADDRESS
POSITION (11: 40) CHAR(30),
CITY
POSITION (41: 70) CHAR(30),
POSTAL_CODE POSITION (71: 85) CHAR(15),
COUNTRY
POSITION (86:115) CHAR(30) )
//
**************************** Bottom of Data *****************

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-45

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1
J E S 2 J O B L O G -- S Y S T E M D I 1 1 -- N O D E M V S D I 1 1
0
07.52.56 JOB00456 ---- FRIDAY,
26 AUG 2011 ---07.52.56 JOB00456 IRR010I USERID TSOUB01 IS ASSIGNED TO THIS JOB.
07.52.56 JOB00456 ICH70001I TSOUB01 LAST ACCESS AT 05:55:07 ON FRIDAY, AUGUST 26, 2011
07.52.56 JOB00456 $HASP373 TSOUB011 STARTED - INIT 1
- CLASS A - SYS DI11
07.52.57 JOB00456 -----TIMINGS (MINS.)----------PAGING COUNTS---07.52.57 JOB00456 -STEPNAME PROCSTEP
RC
EXCP
CONN
TCB
SRB CLOCK
SERV WORKLOAD PAGE SWAP
VIO
SWAPS
0
07.52.57 JOB00456 -UTIL
DSNUPROC
00
764
65
.00
.00
.0
309 BATCH
0
0
0
07.52.57 JOB00456 -TSOUB011 ENDED. NAME-TSOUB01 JOB
TOTAL TCB CPU TIME=
.00 TOTAL ELAPSED TIME=
.0
07.52.57 JOB00456 $HASP395 TSOUB011 ENDED
0------ JES2 JOB STATISTICS ------ 26 AUG 2011 JOB EXECUTION DATE
59 CARDS READ
273 SYSOUT PRINT RECORDS
0 SYSOUT PUNCH RECORDS
17 SYSOUT SPOOL KBYTES
0.01 MINUTES EXECUTION TIME
1
1 //TSOUB011 JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
JOB00456
//
CLASS=A,MSGCLASS=Q,NOTIFY=TSOUB01,REGION=0M
//*
//*
2 //UTIL EXEC DSNBUPRC,SYSTEM=DSNB,UID='TSOUB01',UTPROC=''
3 XXDSNUPROC PROC LIB='DBDSNB.DB2A10.SDSNLOAD',
XX
SYSTEM=DSNB,
XX
SIZE=0K,UID='',UTPROC=''
XX*

pr

Step 1c: LOAD utility output for LOCATION table - part 1 of 6

cl

Ex
Student Exercises

A-46 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

XX**********************************************************************
XX*
*
XX* PROCEDURE-NAME:
DSNBUPRC
*
XX*
*
XX* DESCRIPTIVE-NAME:
UTILITY PROCEDURE
*
XX*
*
XX* FUNCTION: THIS PROCEDURE INVOKES THE ADMF UTILITIES IN THE
*
XX*
BATCH ENVIRONMENT
*
XX*
*
XX* PROCEDURE-OWNER:
UTILITY COMPONENT
*
XX*
*
XX* COMPONENT-INVOKED:
ADMF UTILITIES (ENTRY POINT DSNUTILB).
*
XX*
*
XX* ENVIRONMENT:
BATCH
*
XX*
*
XX* INPUT:
*
XX*
PARAMETERS:
*
XX*
LIB
= THE DATA SET NAME OF THE DB2 PROGRAM LIBRARY. *
XX*
THE DEFAULT LIBRARY NAME IS PREFIX.SDSNLOAD,
*
XX*
WITH PREFIX SET DURING INSTALLATION.
*
XX*
SIZE
= THE REGION SIZE OF THE UTILITIES EXECUTION AREA.*
XX*
THE DEFAULT REGION SIZE IS 2048K.
*
XX*
SYSTEM = THE SUBSYSTEM NAME USED TO IDENTIFY THIS JOB
*
XX*
TO DB2 . THE DEFAULT IS "DSNB".
*
XX*
UID
= THE IDENTIFIER WHICH WILL DEFINE THIS UTILITY
*
XX*
JOB TO DB2. IF THE PARAMETER IS DEFAULTED OR
*
XX*
SET TO A NULL STRING, THE UTILITY FUNCTION WILL *
XX*
USE ITS DEFAULT, USERID.JOBNAME. EACH UTILITY *
XX*
WHICH HAS STARTED AND IS NOT YET TERMINATED
*
XX*
(MAY NOT BE RUNNING) MUST HAVE A UNIQUE UID.
*
XX*
UTPROC = AN OPTIONAL INDICATOR USED TO DETERMINE WHETHER *
XX*
THE USER WISHES TO INITIALLY START THE REQUESTED*
XX*
UTILITY OR TO RESTART A PREVIOUS EXECUTION OF
*
XX*
THE UTILITY. IF OMITTED, THE UTILITY WILL
*
XX*
BE INITIALLY STARTED. OTHERWISE, THE UTILITY
*
XX*
WILL BE RESTARTED BY ENTERING THE FOLLOWING
*
XX*
VALUES:
*
XX*
RESTART(PHASE) = RESTART THE UTILITY AT THE *
XX*
BEGINNING OF THE PHASE EXECUTED
*
XX*
LAST.
*
XX*
RESTART = RESTART THE UTILITY AT THE LAST
*
XX*
OR CURRENT COMMIT POINT.
*
XX*
*
XX* OUTPUT: NONE.
*
XX*
*
XX* EXTERNAL-REFERENCES: NONE.
*
XX*
*
XX* CHANGE-ACTIVITY:
*
XX*
*
XX*
*
XX**********************************************************************

Step 1c: LOAD utility output for LOCATION table - part 2 of 6

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-47

XX*

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

4 XXDSNUPROC EXEC PGM=DSNUTILB,REGION=&SIZE,


XX
PARM='&SYSTEM,&UID,&UTPROC'
IEFC653I SUBSTITUTION JCL - PGM=DSNUTILB,REGION=0K,PARM='DSNB,TSOUB01,'
5 XXSTEPLIB DD
DSN=&LIB,DISP=SHR
XX*
XX**********************************************************************
XX*
*
XX* THE FOLLOWING DEFINE THE UTILITIES' PRINT DATA SETS
*
XX*
*
XX**********************************************************************
XX*
IEFC653I SUBSTITUTION JCL - DSN=DBDSNB.DB2A10.SDSNLOAD,DISP=SHR
6 XXSYSPRINT DD
SYSOUT=*
7 XXUTPRINT DD
SYSOUT=*
8 XXSYSUDUMP DD
SYSOUT=*
XX*DSNBUPRC PEND
REMOVE * FOR USE AS INSTREAM PROCEDURE
//*
//**********************************************
//*
//* GENERATING JCL FOR THE LOAD UTILITY
//* DATE: 08/26/11
TIME: 07:52:39
//*
//**********************************************
//*
9 //DSNUPROC.SORTWK01 DD DSN=TSOUB01.SORTWK01,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
10 //DSNUPROC.SORTWK02 DD DSN=TSOUB01.SORTWK02,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
11 //DSNUPROC.SORTWK03 DD DSN=TSOUB01.SORTWK03,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
12 //DSNUPROC.SORTWK04 DD DSN=TSOUB01.SORTWK04,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
13 //DSNUPROC.SYSREC DD DSN=TSOUB01.CV83.TSLOCN.DATA,
//
DISP=OLD
14 //DSNUPROC.SYSDISC DD DSN=TSOUB01.CV83.TSLOCN.DISCARD,
//
DISP=(MOD,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
15 //DSNUPROC.SYSUT1 DD DSN=TSOUB01.SYSUT1,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
16 //DSNUPROC.SORTOUT DD DSN=TSOUB01.SORTOUT,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
17 //DSNUPROC.SYSERR DD DSN=TSOUB01.SYSERR,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA

pr

Step 1c: LOAD utility output for LOCATION table - part 3 of 6

cl

Ex
Student Exercises

A-48 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

18 //DSNUPROC.SYSMAP DD DSN=TSOUB01.SYSMAP,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
19 //DSNUPROC.SYSIN
DD *
1
STMT NO. MESSAGE
2 IEFC001I PROCEDURE DSNBUPRC WAS EXPANDED USING SYSTEM LIBRARY SYS2.DB2.PROCLIB
ICH70001I TSOUB01 LAST ACCESS AT 05:55:07 ON FRIDAY, AUGUST 26, 2011
IEF236I ALLOC. FOR TSOUB011 DSNUPROC UTIL
IGD103I SMS ALLOCATED TO DDNAME STEPLIB
IEF237I JES2 ALLOCATED TO SYSPRINT
IEF237I JES2 ALLOCATED TO UTPRINT
IEF237I JES2 ALLOCATED TO SYSUDUMP
IGD101I SMS ALLOCATED TO DDNAME (SORTWK01)
DSN (TSOUB01.SORTWK01
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS004
IGD101I SMS ALLOCATED TO DDNAME (SORTWK02)
DSN (TSOUB01.SORTWK02
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS002
IGD101I SMS ALLOCATED TO DDNAME (SORTWK03)
DSN (TSOUB01.SORTWK03
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS001
IGD101I SMS ALLOCATED TO DDNAME (SORTWK04)
DSN (TSOUB01.SORTWK04
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS002
IGD103I SMS ALLOCATED TO DDNAME SYSREC
IGD101I SMS ALLOCATED TO DDNAME (SYSDISC )
DSN (TSOUB01.CV83.TSLOCN.DISCARD
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS004
IGD101I SMS ALLOCATED TO DDNAME (SYSUT1 )
DSN (TSOUB01.SYSUT1
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS001
IGD101I SMS ALLOCATED TO DDNAME (SORTOUT )
DSN (TSOUB01.SORTOUT
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS002
IGD101I SMS ALLOCATED TO DDNAME (SYSERR )
DSN (TSOUB01.SYSERR
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS001
IGD101I SMS ALLOCATED TO DDNAME (SYSMAP )
DSN (TSOUB01.SYSMAP
)
STORCLAS (BASE) MGMTCLAS (STANDARD) DATACLAS (
)
VOL SER NOS= SMS004
IEF237I JES2 ALLOCATED TO SYSIN
IEF142I TSOUB011 DSNUPROC UTIL - STEP WAS EXECUTED - COND CODE 0000
IGD104I DBDSNB.DB2A10.SDSNLOAD
RETAINED, DDNAME=STEPLIB
IEF285I
TSOUB01.TSOUB011.JOB00456.D0000102.?
SYSOUT
IEF285I
TSOUB01.TSOUB011.JOB00456.D0000103.?
SYSOUT
IEF285I
TSOUB01.TSOUB011.JOB00456.D0000104.?
SYSOUT

Step 1c: LOAD utility output for LOCATION table - part 4 of 6

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-49

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

IGD105I TSOUB01.SORTWK01
DELETED,
DDNAME=SORTWK01
IGD105I TSOUB01.SORTWK02
DELETED,
DDNAME=SORTWK02
IGD105I TSOUB01.SORTWK03
DELETED,
DDNAME=SORTWK03
IGD105I TSOUB01.SORTWK04
DELETED,
DDNAME=SORTWK04
IGD104I TSOUB01.CV83.TSLOCN.DATA
RETAINED, DDNAME=SYSREC
IGD104I TSOUB01.CV83.TSLOCN.DISCARD
RETAINED, DDNAME=SYSDISC
IGD105I TSOUB01.SYSUT1
DELETED,
DDNAME=SYSUT1
IGD105I TSOUB01.SORTOUT
DELETED,
DDNAME=SORTOUT
IGD105I TSOUB01.SYSERR
DELETED,
DDNAME=SYSERR
IGD105I TSOUB01.SYSMAP
DELETED,
DDNAME=SYSMAP
IEF285I
TSOUB01.TSOUB011.JOB00456.D0000101.?
SYSIN
IEF373I STEP/DSNUPROC/START 2011238.0752
IEF032I STEP/DSNUPROC/STOP 2011238.0752
CPU:
0 HR 00 MIN 00.06 SEC
SRB:
0 HR 00 MIN 00.00 SEC
VIRT: 1232K SYS:
292K EXT: 1575816K SYS:
11616K
IEF375I JOB/TSOUB011/START 2011238.0752
IEF033I JOB/TSOUB011/STOP 2011238.0752
CPU:
0 HR 00 MIN 00.06 SEC
SRB:
0 HR 00 MIN 00.00 SEC
1DSNU000I
238 07:52:56.36 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
238 07:52:56.42 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
238 07:52:56.53 DSNUGUTC - LOAD DATA
DSNU650I -DSNB 238 07:52:56.56 DSNURWI - INTO TABLE LOCATION
DSNU650I -DSNB 238 07:52:56.56 DSNURWI (LOCID POSITION(1:10) CHAR(10),
DSNU650I -DSNB 238 07:52:56.56 DSNURWI ADDRESS POSITION(11:40) CHAR(30),
DSNU650I -DSNB 238 07:52:56.56 DSNURWI CITY POSITION(41:70) CHAR(30),
DSNU650I -DSNB 238 07:52:56.56 DSNURWI POSTAL_CODE POSITION(71:85) CHAR(15),
DSNU650I -DSNB 238 07:52:56.56 DSNURWI COUNTRY POSITION(86:115) CHAR(30))
DSNU304I -DSNB 238 07:52:56.77 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=4 FOR TABLE TSOUB01.LOCATION
DSNU1147I -DSNB 238 07:52:56.77 DSNURWT - (RE)LOAD PHASE STATISTICS - TOTAL NUMBER OF RECORDS LOADED=4 FOR TABLESPACE
WWV8301D.TSLOCN
DSNU302I
238 07:52:56.77 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=4
DSNU300I
238 07:52:56.77 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU042I
238 07:52:56.96 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=4
ELAPSED TIME=00:00:00
DSNU349I -DSNB 238 07:52:57.01 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=4 FOR INDEX TSOUB01.IXLOCN1
DSNU258I
238 07:52:57.02 DSNURBXD - BUILD PHASE STATISTICS - NUMBER OF INDEXES=1
DSNU259I
238 07:52:57.02 DSNURBXD - BUILD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
238 07:52:57.03 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

pr

Step 1c: LOAD utility output for LOCATION table - part 5 of 6

cl

Ex
Student Exercises

A-50 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

0
G
0
0
0
0

G
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0

1ICE200I
ICE201I
ICE751I
ICE143I
ICE250I
ICE000I
0

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

ICE201I
ICE751I
ICE193I
ICE089I
ICE093I
ICE156I
ICE127I
ICE128I
ICE129I
ICE130I
ICE131I
ICE132I
ICE133I
ICE235I
ICE236I
ICE750I
ICE752I
ICE751I
ICE091I
ICE080I
ICE055I
ICE054I
ICE134I
ICE253I
ICE191I
ICE165I
ICE199I
ICE299I
ICE180I
ICE188I
ICE052I

IDENTIFIER FROM CALLING PROGRAM IS 0000


RECORD TYPE IS F - DATA STARTS IN POSITION 1
C5-K59562 C6-BASE
C7-K58148 C8-K58148 E4-K58148 C9-BASE
E5-K59517 E7-K58148
BLOCKSET
SORT TECHNIQUE SELECTED
VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND MORE
- CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 07:52 ON FRI AUG 26, 2011 SORT FIELDS=(00006.0,00000.4,A,00012.0,00012.0,A,00001.0,00005.0,A),FOR*
MAT=BI,FILSZ=U000000000000004
RECORD TYPE=F,LENGTH=(00023,00023,00023)
OPTION MSGPRT=ALL,MSGDDN=UTPRINT,MAINSIZE=MAX
RECORD TYPE IS F - DATA STARTS IN POSITION 1
C5-K59562 C6-BASE
C7-K58148 C8-K58148 E4-K58148 C9-BASE
E5-K59517 E7-K58148
ICEAM2 INVOCATION ENVIRONMENT IN EFFECT - ICEAM2 ENVIRONMENT SELECTED
TSOUB011.UTIL
.DSNUPROC, INPUT LRECL = 23, TYPE = F
MAIN STORAGE = (MAX,6291456,6291456)
MAIN STORAGE ABOVE 16MB = (6234096,6234096)
OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y,RESET=Y,VSAMEMT=Y,DYNSPC=256
OPTIONS: SIZE=6291456,MAXLIM=1048576,MINLIM=450560,EQUALS=N,LIST=Y,ERET=RC16 ,MSGDDN=UTPRINT
OPTIONS: VIO=N,RESDNT=ALL ,SMF=NO
,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=N,DYNALOC=N
,ABCODE=MSG
OPTIONS: RESALL=4096,RESINV=0,SVC=109 ,CHECK=Y,WRKREL=N,OUTREL=Y,CKPT=N,COBEXIT=COB2
OPTIONS: TMAXLIM=6291456,ARESALL=0,ARESINV=0,OVERRGN=16384,CINV=Y,CFW=Y,DSA=0
OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE
,EXITCK=S,PARMDDN=DFSPARM ,FSZEST=N
OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=0,SOLRF=Y,VLLONG=N,VSAMIO=N,MOSIZE=MAX
OPTIONS: NULLOUT=RC0
OPTIONS: DYNAPCT=10 ,MOWRK=Y
DC 0 TC 0 CS DSVVV KSZ 18 VSZ 18
FSZ=4 RU IGN=0 C AVG=24 0 WSP=1 U DYN=0 0
DE-K58148 D5-K58148 D9-K58148 E8-K58148
OUTPUT LRECL = 23, TYPE = F
IN MAIN STORAGE SORT
INSERT 4, DELETE 4
RECORDS - IN: 0, OUT: 0
NUMBER OF BYTES SORTED: 92
RECORDS SORTED - PROCESSED: 4, EXPECTED: 4
DFSORT SVC NOT AVAILABLE - PERFORMANCE MAY BE DEGRADED
TOTAL WORK DATA SET TRACKS ALLOCATED: 60 , TRACKS USED: 0
MEMORY OBJECT USED AS MAIN STORAGE = 0M BYTES
MEMORY OBJECT USED AS WORK STORAGE = 0M BYTES
HIPERSPACE STORAGE USED = 0K BYTES
DATA SPACE STORAGE USED = 0K BYTES
END OF DFSORT

Step 1c: LOAD utility output for LOCATION table - part 6 of 6

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-51

Student Exercises

Load the tables DEPARTMENT and EMPLOYEE (a cycle)


Step 2: Utility control statement for loading DEPARTMENT

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.CNTL(L6TSDEPT) - 01.00
Columns 0
===>
Scroll
***************************** Top of Data *******************
LOAD DATA ENFORCE NO
INTO TABLE DEPARTMENT
(DEPTNO
POSITION(01:03) CHAR(03)
,
SUPERIOR_DEPTNO
POSITION(05:07) CHAR(03)
NULLIF(04)=X'FF',
MGRNO
POSITION(09:14) CHAR(06)
NULLIF(08)=X'FF',
NAME
POSITION(15)
VARCHAR
)
**************************** Bottom of Data *****************

The above control statement loads the following input data (length of column NAME stored
in (15:16), for example X001C = 28 = length of SPIFFY COMPUTER SERVICE DIV.).
TSOUB01.CV83.TSDEPT.DATA
===>
***************************** Top of Data *****
----+----1----+----2----+----3----+----4----+-A00
000010 SPIFFY COMPUTER SERVICE DIV.
CFFF0000FFFFFF01EDCCCE4CDDDEECD4ECDECCC4CCE4444
100F00000000100C279668036474359025959350495B000
-----------------------------------------------

Step 3: How does the LOAD utility know when to set MGRNO column
value for a row to NULL?

The utility control statement specifies that the MGRNO column value for a row should be
set to NULL when byte 8 of the input record contains X'FF'.

cl

Step 4: How does the LOAD utility know the length of the input data for
column NAME?

Ex

The LOAD utility assumes that the first 2 bytes (15-16) of the input data for column NAME
contain the length of the input data.

Step 5: Should the control statement specify ENFORCE CONSTRAINTS


or ENFORCE NO?

pr

The control statement should specify ENFORCE NO, because one of the parent tables
(EMPLOYEE) has not been loaded yet.

A-52 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

12:54:03.14 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


12:54:03.17 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
12:54:03.18 DSNUGUTC - LOAD DATA ENFORCE NO
239 12:54:03.18 DSNURWI - INTO TABLE DEPARTMENT
239 12:54:03.18 DSNURWI (DEPTNO POSITION(1:3) CHAR(3),
239 12:54:03.18 DSNURWI SUPERIOR_DEPTNO POSITION(5:7) CHAR(3) NULLIF(4)=X'FF',
239 12:54:03.18 DSNURWI MGRNO POSITION(9:14) CHAR(6) NULLIF(8)=X'FF',
239 12:54:03.18 DSNURWI NAME POSITION(15) VARCHAR)
239 12:54:03.32 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=13 FOR TABLE TSOUB01.DEPARTMENT
239 12:54:03.32 DSNURWT - (RE)LOAD PHASE STATISTICS - TOTAL NUMBER OF RECORDS LOADED=13 FOR TABLESPACE

Copyright IBM Corp. 1993, 2011

ERROR SEVERITY :1
INPUT RECORD
:
12
DISCARD RECORD :
1
ERROR TYPE
:
DUP. KEY
RELATED ERROR
:
0
TABLE NAME
: TSOUB01.DEPARTMENT
FIELD/FANSET NAME: TSOUB01.IXDEPT1
ERROR SEVERITY :1
INPUT RECORD
:
13
DISCARD RECORD :
2
ERROR TYPE
:
DUP. KEY
RELATED ERROR
:
12
TABLE NAME
: TSOUB01.DEPARTMENT
FIELD/FANSET NAME: TSOUB01.IXDEPT1
DSNU396I
239 12:54:03.69 DSNURREP - REPORT PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU561I -DSNB 239 12:54:03.70 DSNUGSRX - TABLESPACE WWV8301D.TSDEPT PARTITION 1 IS IN CHECK PENDING
DSNU010I
239 12:54:03.72 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=4

12:54:03.32 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=13


12:54:03.32 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
12:54:03.33 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=39
ELAPSED TIME=00:00:00
DSNU345I
239 12:54:03.33 DSNURBXD - UNIQUE INDEX KEY DUPLICATES KEY FROM INPUT RECORD
'12' LOADED AT RID X'000000020C',
INDEX = TSOUB01.IXDEPT1,
TABLE = TSOUB01.DEPARTMENT,
RECNO = 13,
RID
= X'000000020D'
DSNU349I -DSNB 239 12:54:03.35 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=11 FOR INDEX TSOUB01.IXDEPT1
DSNU349I -DSNB 239 12:54:03.39 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=13 FOR INDEX TSOUB01.IXDEPT2
DSNU349I -DSNB 239 12:54:03.42 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=13 FOR INDEX TSOUB01.IXDEPT3
DSNU258I
239 12:54:03.42 DSNURBXD - BUILD PHASE STATISTICS - NUMBER OF INDEXES=3
DSNU343I
239 12:54:03.42 DSNURBXD - BUILD PHASE STATISTICS - 2 DUPLICATE KEY ERRORS ENCOUNTERED
DSNU259I
239 12:54:03.42 DSNURBXD - BUILD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU355I
239 12:54:03.52 DSNURVIX - INDEXVAL PHASE STATISTICS - 2 DUPLICATE KEY ERRORS, KEY EVALUATION ERRORS, XML
ERRORS, OR LOB ERRORS WERE CORRECTED BY DELETING 2 DATA ROWS
DSNU356I
239 12:54:03.52 DSNURVIX - INDEXVAL PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU375I
239 12:54:03.65 DSNURDNP - DISCARD PHASE STATISTICS - 2 INPUT DATA SET RECORDS DISCARDED
DSNU376I
239 12:54:03.66 DSNURDIS - DISCARD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU399I
239 12:54:03.69 DSNURRIS - LOAD UTILITY ERROR SUMMARY REPORT

1DSNU000I
239
DSNU1044I
239
0DSNU050I
239
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU304I -DSNB
DSNU1147I -DSNB
WWV8301D.TSDEPT
DSNU302I
239
DSNU300I
239
DSNU042I
239

Steps 6 to 8: LOAD utility output for DEPARTMENT table - just the DB2 messages

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-53

Student Exercises

Step 8: Questions relating to load of DEPARTMENT table


1. Why were two rows deleted from the INDEXVAL phase?
Input records 12 and 13 are duplicates, since both the records have the same DEPTNO
value, causing unique index violation. Therefore, both rows which were inserted before the
validation phase are removed.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

2. Has table space TSDEPT been placed in a pending state?

Yes, table space TSDEPT is placed in check pending state, as can be seen from the output
of the LOAD utility, and also from the DISPLAY DATABASE command:

Steps 9 to 10: -DISPLAY DATABASE command output


-DIS DB(WWV8301D) SPACE(TS*)

pr

Ex

cl

DSNT360I -DSNB ***********************************


DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV8301D STATUS = RW
DBD LENGTH = 16142
DSNT397I -DSNB
NAME
TYPE PART STATUS
PHYERRLO PHYERRHI CATALOG PIECE
-------- ---- ----- ----------------- -------- -------- -------- ----TSDEPT
TS
0001 RW,CHKP
TSDEPT
TS
RW,CHKP
TSEMPL
TS
0001 RW
-THRU
0003
TSEMPL
TS
RW
TSLOCN
TS
RW
TSPROJ
TS
RW
******* DISPLAY OF DATABASE WWV8301D ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
***

A-54 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 11: Utility control card to load table EMPLOYEE

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.CNTL(L6TSEMPL) - 01.00
Columns 00
===>
Scroll
***************************** Top of Data ********************
LOAD DATA
INTO TABLE EMPLOYEE
(EMPNO
POSITION(001:006) CHAR(06)
,
FIRST_NAME
POSITION(007:026) CHAR(20)
,
MIDDLE_INITIAL
POSITION(028:028) CHAR(01)
NULLIF(027)=X'FF',
SEX
POSITION(029:029) CHAR(01)
,
BIRTHDATE
POSITION(031:040) DATE EXTERNAL
NULLIF(030)=X'FF',
PHONE
POSITION(042:045) CHAR(04)
NULLIF(041)=X'FF',
HIRING_DATE
POSITION(047:056) DATE EXTERNAL
NULLIF(046)=X'FF',
JOB
POSITION(058:077) CHAR(20)
NULLIF(057)=X'FF',
EDUCATION
POSITION(078:079) SMALLINT
,
SALARY
POSITION(081:085) DECIMAL
NULLIF(080)=X'FF',
BONUS
POSITION(087:091) DECIMAL
NULLIF(086)=X'FF',
COMMISSION
POSITION(093:097) DECIMAL
NULLIF(092)=X'FF',
DEPTNO
POSITION(099:101) CHAR(003)
NULLIF(098)=X'FF',
LOCID
POSITION(103:112) CHAR(010)
NULLIF(102)=X'FF',
LAST_NAME
POSITION(113)
VARCHAR
)
**************************** Bottom of Data *******************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-55

Student Exercises

Input data for EMPLOYEE

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.TSEMPL.DATA
***************************** Top of Data *********
----------------------------------------------------+----8----+----9----+----0----+----1----+----2----+----F----+----F----+----F----+----F----+----F----+----8----+----9----+----0----+----1----+----2----------------------------------------------------
A00 DE71083-01 HAAS
44444010057000000000002000CFF0CCFFFFF6FF00CCCE44444
000000200250C00100C00420C01000457108300104811200000
--------------------------------------------------
B01 DE71083-01 THOMPSON
44444010042000008000003000CFF0CCFFFFF6FF00ECDDDEDD4
000000200150C00000C00300C02010457108300108386472650

Salary is stored in (81:85), for example for HAAS: X005275000C, thus 52750.00

Why can the control statement specify (by default) ENFORCE CONSTRAINTS?

pr

Ex

cl

The control statement can specify ENFORCE CONSTRAINTS, because both of


EMPLOYEEs parent tables, LOCATION and DEPARTMENT, have been loaded and the
LOAD utility can test for the existence of the primary key values in spite of CHKP on
TSDEPT.

A-56 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

239
239
239
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB

13:01:37.72 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


13:01:37.75 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
13:01:37.76 DSNUGUTC - LOAD DATA
239 13:01:37.76 DSNURWI - INTO TABLE EMPLOYEE
239 13:01:37.76 DSNURWI (EMPNO POSITION(1:6) CHAR(6),
239 13:01:37.76 DSNURWI FIRST_NAME POSITION(7:26) CHAR(20),
239 13:01:37.76 DSNURWI MIDDLE_INITIAL POSITION(28:28) CHAR(1) NULLIF(27)=X'FF',
239 13:01:37.76 DSNURWI SEX POSITION(29:29) CHAR(1),
239 13:01:37.76 DSNURWI BIRTHDATE POSITION(31:40) DATE EXTERNAL NULLIF(30)=X'FF',
239 13:01:37.76 DSNURWI PHONE POSITION(42:45) CHAR(4) NULLIF(41)=X'FF',
239 13:01:37.76 DSNURWI HIRING_DATE POSITION(47:56) DATE EXTERNAL NULLIF(46)=X'FF',
239 13:01:37.76 DSNURWI JOB POSITION(58:77) CHAR(20) NULLIF(57)=X'FF',
239 13:01:37.76 DSNURWI EDUCATION POSITION(78:79) SMALLINT,
239 13:01:37.76 DSNURWI SALARY POSITION(81:85) DECIMAL NULLIF(80)=X'FF',
239 13:01:37.76 DSNURWI BONUS POSITION(87:91) DECIMAL NULLIF(86)=X'FF',
239 13:01:37.76 DSNURWI COMMISSION POSITION(93:97) DECIMAL NULLIF(92)=X'FF',
239 13:01:37.76 DSNURWI DEPTNO POSITION(99:101) CHAR(3) NULLIF(98)=X'FF',
239 13:01:37.76 DSNURWI LOCID POSITION(103:112) CHAR(10) NULLIF(102)=X'FF',
239 13:01:37.76 DSNURWI LAST_NAME POSITION(113) VARCHAR)
239 13:01:37.93 DSNURCON - RECORD (8) WILL BE DISCARDED DUE TO 'BIRTHDATE'
CONVERSION ERROR FOR TSOUB01.EMPLOYEE
ERROR CODE '14 - INPUT IS INVALID FOR DATE/TIME'
DSNU353I -DSNB 239 13:01:37.93 DSNURWBF - RECORD (10) WILL BE DISCARDED DUE TO CHECK CONSTRAINT SEX VIOLATION ON TABLE
TSOUB01.EMPLOYEE
DSNU310I -DSNB 239 13:01:37.94 DSNURCON - RECORD (20) WILL BE DISCARDED DUE TO 'SALARY'
CONVERSION ERROR FOR TSOUB01.EMPLOYEE
ERROR CODE '04 - INPUT PACKED DECIMAL IS IN ERROR'
DSNU304I -DSNB 239 13:01:38.00 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=39 FOR TABLE TSOUB01.EMPLOYEE
DSNU1147I -DSNB 239 13:01:38.00 DSNURWT - (RE)LOAD PHASE STATISTICS - TOTAL NUMBER OF RECORDS LOADED=39 FOR TABLESPACE
WWV8301D.TSEMPL
DSNU1150I -DSNB 239 13:01:38.00 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS NOT LOADED=3
DSNU302I
239 13:01:38.00 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=42
DSNU300I
239 13:01:38.00 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU042I
239 13:01:38.00 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=117
ELAPSED TIME=00:00:00
DSNU348I -DSNB 239 13:01:38.04 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=16 FOR INDEX TSOUB01.IXEMPL1 PART 1
DSNU348I -DSNB 239 13:01:38.07 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=11 FOR INDEX TSOUB01.IXEMPL1 PART 2
DSNU348I -DSNB 239 13:01:38.10 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=12 FOR INDEX TSOUB01.IXEMPL1 PART 3
DSNU349I -DSNB 239 13:01:38.13 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=39 FOR INDEX TSOUB01.IXEMPL2
DSNU349I -DSNB 239 13:01:38.16 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=39 FOR INDEX TSOUB01.IXEMPL3
DSNU258I
239 13:01:38.17 DSNURBXD - BUILD PHASE STATISTICS - NUMBER OF INDEXES=3
DSNU259I
239 13:01:38.17 DSNURBXD - BUILD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU361I -DSNB 239 13:01:38.18 DSNURCRI - FOREIGN KEY HAS NO PRIMARY KEY FOR RELATIONSHIP TSOUB01.EMPLOYEE.DE
INPUT RECORD NUMBER=12, RID=X'000000020A'
DSNU361I -DSNB 239 13:01:38.19 DSNURCRI - FOREIGN KEY HAS NO PRIMARY KEY FOR RELATIONSHIP TSOUB01.EMPLOYEE.DE
INPUT RECORD NUMBER=13, RID=X'000000020B'
DSNU363I -DSNB 239 13:01:38.19 DSNURCRI - ENFORCE PHASE STATISTICS RELATIONSHIP TSOUB01.EMPLOYEE.DE
FOREIGN KEYS CHECKED=39
CONSTRAINT VIOLATIONS ENCOUNTERED=2
DSNU361I -DSNB 239 13:01:38.19 DSNURCRI - FOREIGN KEY HAS NO PRIMARY KEY FOR RELATIONSHIP TSOUB01.EMPLOYEE.LE
INPUT RECORD NUMBER=34, RID=X'0020000204'
DSNU363I -DSNB 239 13:01:38.19 DSNURCRI - ENFORCE PHASE STATISTICS RELATIONSHIP TSOUB01.EMPLOYEE.LE
FOREIGN KEYS CHECKED=39
CONSTRAINT VIOLATIONS ENCOUNTERED=1
DSNU367I -DSNB 239 13:01:38.31 DSNURRRI - ENFORCE PHASE STATISTICS - 3 ROWS DELETED FROM TABLE TSOUB01.EMPLOYEE
DSNU369I
239 13:01:38.32 DSNURENF - ENFORCE PHASE COMPLETE, ELAPSED TIME=00:00:00

1DSNU000I
DSNU1044I
0DSNU050I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU310I

Steps 12 to 14: LOAD utility output for EMPLOYEE table - just the DB2 messages, part 1 of 2

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-57

pr

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

239 13:01:38.45 DSNURDNP - DISCARD PHASE STATISTICS - 6 INPUT DATA SET RECORDS DISCARDED
239 13:01:38.45 DSNURDIS - DISCARD PHASE COMPLETE, ELAPSED TIME=00:00:00
239 13:01:38.48 DSNURRIS - LOAD UTILITY ERROR SUMMARY REPORT

ERROR SEVERITY :1
INPUT RECORD
:
8
DISCARD RECORD :
1
ERROR TYPE
:
CONVERSION
RELATED ERROR
:
0
TABLE NAME
: TSOUB01.EMPLOYEE
FIELD/FANSET NAME: BIRTHDATE
ERROR SEVERITY :1
INPUT RECORD
:
10
DISCARD RECORD :
2
ERROR TYPE
:
CHK. CONSTR.
RELATED ERROR
:
0
TABLE NAME
: TSOUB01.EMPLOYEE
FIELD/FANSET NAME: SEX.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR SEVERITY :1
INPUT RECORD
:
12
DISCARD RECORD :
3
ERROR TYPE
:
REF. INTEG.
RELATED ERROR
:
0
TABLE NAME
: TSOUB01.EMPLOYEE
FIELD/FANSET NAME: DE
ERROR SEVERITY :1
INPUT RECORD
:
13
DISCARD RECORD :
4
ERROR TYPE
:
REF. INTEG.
RELATED ERROR
:
0
TABLE NAME
: TSOUB01.EMPLOYEE
FIELD/FANSET NAME: DE
ERROR SEVERITY :1
INPUT RECORD
:
20
DISCARD RECORD :
5
ERROR TYPE
:
CONVERSION
RELATED ERROR
:
0
TABLE NAME
: TSOUB01.EMPLOYEE
FIELD/FANSET NAME: SALARY
ERROR SEVERITY :1
INPUT RECORD
:
34
DISCARD RECORD :
6
ERROR TYPE
:
REF. INTEG.
RELATED ERROR
:
0
TABLE NAME
: TSOUB01.EMPLOYEE
FIELD/FANSET NAME: LE
DSNU396I
239 13:01:38.51 DSNURREP - REPORT PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
239 13:01:38.55 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=4

DSNU375I
DSNU376I
DSNU399I

Steps 12 to 14: LOAD utility output for EMPLOYEE table - just the DB2 messages, part 2 of 2

cl

Ex
Student Exercises

A-58 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Step 14: Questions relating to load of EMPLOYEE table


1. Why were three rows discarded during the RELOAD phase?
a. Record number 8 has a value for BIRTHDATE which causes a conversion error.
b. Record number 10 has a value for column SEX which violates the check constraint
on the column.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

c. Record number 20 has a value for SALARY which causes a conversion error.

2. Why were three rows discarded during the ENFORCE phase?

a. Record number 12 has a value for DEPTNO which does not exist in the
DEPARTMENT table and causes an RI violation (relationship DE; see
FIELD/FANSET NAME in the job output).
b. Record number 13 has a value for DEPTNO which does not exist in the
DEPARTMENT table and causes an RI violation (relationship DE; see
FIELD/FANSET NAME in the job output).

pr

Ex

cl

c. Record number 34 has a value for LOCID which does not exist in the LOCATION
table and causes an RI violation (relationship LE; see FIELD/FANSET NAME in the
job output).

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-59

Student Exercises

Checking a cycle via CHECK DATA


Step 15: Create exception tables
---------+---------+---------+---------+---------+---------+
CREATE TABLESPACE TSEXCEPT IN WWV8301D;

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
CREATE TABLE EX_DEPARTMENT
LIKE DEPARTMENT

IN WWV8301D.TSEXCEPT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
COMMIT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
ALTER TABLE EX_DEPARTMENT
ADD RID CHAR(5);

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
ALTER TABLE EX_DEPARTMENT

ADD TIME TIMESTAMP NOT NULL WITH DEFAULT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

cl

---------+---------+---------+---------+---------+---------+
CREATE TABLE EX_EMPLOYEE

Ex

LIKE EMPLOYEE

IN WWV8301D.TSEXCEPT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

pr

---------+---------+---------+---------+---------+---------+
COMMIT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+

A-60 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

ALTER TABLE EX_EMPLOYEE


ADD RID CHAR(5);
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+
ALTER TABLE EX_EMPLOYEE

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

ADD TIME TIMESTAMP NOT NULL WITH DEFAULT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
CREATE TABLE EX_PROJECT
LIKE PROJECT

IN WWV8301D.TSEXCEPT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
COMMIT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
ALTER TABLE EX_PROJECT
ADD RID CHAR(5);

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
ALTER TABLE EX_PROJECT

ADD TIME TIMESTAMP NOT NULL WITH DEFAULT;

cl

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+

Ex

CREATE TABLE EX_ON_PROJECT


LIKE ON_PROJECT

IN WWV8301D.TSEXCEPT;

pr

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+
COMMIT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-61

Student Exercises

ALTER TABLE EX_ON_PROJECT


ADD RID CHAR(5);
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+
ALTER TABLE EX_ON_PROJECT

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

ADD TIME TIMESTAMP NOT NULL WITH DEFAULT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
CREATE TABLE EX_ACTIVITY
LIKE ACTIVITY

IN WWV8301D.TSEXCEPT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
COMMIT;

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+
ALTER TABLE EX_ACTIVITY
ADD RID CHAR(5);

---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+---ALTER TABLE EX_ACTIVITY

ADD TIME TIMESTAMP NOT NULL WITH DEFAULT;

cl

---------+---------+---------+---------+---------+---------+---DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+----

Ex

DSNE617I COMMIT PERFORMED, SQLCODE IS 0

DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

---------+---------+---------+---------+---------+---------+----

pr

DSNE601I SQL STATEMENTS ASSUMED TO BE BETWEEN COLUMNS 1 AND 72


DSNE620I NUMBER OF SQL STATEMENTS PROCESSED IS 21
DSNE621I NUMBER OF INPUT RECORDS READ IS 62
DSNE622I NUMBER OF OUTPUT RECORDS WRITTEN IS 133

A-62 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1DSNU000I
241 01:59:07.22 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 01:59:07.25 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 01:59:07.25 DSNUGUTC - CHECK DATA TABLESPACE WWV8301D.TSDEPT FOR EXCEPTION IN DEPARTMENT USE
EX_DEPARTMENT DELETE NO
DSNU726I -DSNB 241 01:59:07.26 DSNUKINP - SCOPE PENDING IS ACTIVE, BUT THE ENTIRE
TABLE SPACE 'WWV8301D.TSDEPT' MUST BE CHECKED
DSNU730I
241 01:59:07.36 DSNUKDST - CHECKING TABLE TSOUB01.DEPARTMENT
DSNU042I
241 01:59:07.48 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=2
ELAPSED TIME=00:00:00
DSNU733I
241 01:59:07.48 DSNUKERK - ROW (RID=X'000000020A') HAS NO PARENT FOR TSOUB01.DEPARTMENT.ED
DSNU733I
241 01:59:07.48 DSNUKERK - ROW (RID=X'000000020B') HAS NO PARENT FOR TSOUB01.DEPARTMENT.DD
DSNU739I
241 01:59:07.48 DSNUKDAT - CHECK TABLE TSOUB01.DEPARTMENT COMPLETE, ELAPSED TIME=00:00:00
DSNU561I -DSNB 241 01:59:07.49 DSNUGSRX - TABLESPACE WWV8301D.TSDEPT PARTITION 1 IS IN CHECK PENDING
DSNU749I
241 01:59:07.49 DSNUK001 - CHECK DATA COMPLETE,ELAPSED TIME=00:00:00
DSNU010I
241 01:59:07.50 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=4

Steps 16 to 18: CHECK DATA utility output (DELETE NO) - just the DB2 messages

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-63

Student Exercises

Step 18: Questions relating to the CHECK DATA utility


1. Has table space TSDEPT remained in check pending status?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Yes, table space TSDEPT has remained in check pending status, as revealed by the
output of the CHECK DATA utility. As long as any rows exist in the table which violate
either check constraints or RI constraints, the table space remains in check pending
status.
2. How many rows has CHECK DATA found to be invalid, and why?
CHECK DATA found two rows to be invalid.

A row has a value for MGRNO, and EMPNO with this value does not exist in the
EMPLOYEE table, causing an RI constraint violation (ROW (RID=X'000000020A') HAS
NO PARENT FOR TSOUB01.DEPARTMENT.ED, that is, relationship ED).

pr

Ex

cl

A row has a value for SUPERIOR_DEPTNO, and DEPTNO with this value does not
exist in the DEPARTMENT table, causing an RI constraint violation (ROW
(RID=X'000000020B') HAS NO PARENT FOR TSOUB01.DEPARTMENT.DD, that is,
relationship DD).

A-64 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 19: Read exception tables

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+
SELECT TIME(TIME) AS TIME, DEPTNO, SUPERIOR_DEPTNO, MGRNO,
SUBSTR(NAME, 1, 16) AS NAME, HEX(RID) AS RID
FROM EX_DEPARTMENT;
---------+---------+---------+---------+---------+---------+---------+
TIME
DEPTNO SUPERIOR_DEPTNO MGRNO
NAME
RID
---------+---------+---------+---------+---------+---------+---------+
01.59.07 E31
E01
000101 SOFTWARE SUPP-31 000000020A
01.59.07 E41
X01
000102 SOFTWARE SUPP-41 000000020B
DSNE610I NUMBER OF ROWS DISPLAYED IS 2
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+

Remember: Columns RID [CHAR(5)] and TIME [TIMESTAMP] are additional columns.
CHECK DATA job output (see above) indicates that:

1. Row with RID ...020A has no parent for relation ED. Hence, we can conclude that
MGRNO value 000101 has no parent value in column EMPNO of table EMPLOYEE.
2. Row with RID ...020B has no parent for relation DD. Hence, we can conclude that
SUPERIOR_DEPTNO value X01 has no parent value in column DEPTNO of table
DEPARTMENT.

cl

---------+---------+---------+---------+---------+---------+---------+
SELECT TIME(TIME) AS TIME, EMPNO, DEPTNO,
SUBSTR(FIRST_NAME, 1, 10) AS FIRST_NAME,
SUBSTR(LAST_NAME, 1, 10) AS LAST_NAME,
SUBSTR(JOB, 1, 10) AS JOB, HEX(RID) AS RID
FROM EX_EMPLOYEE;
---------+---------+---------+---------+---------+---------+---------+
TIME
EMPNO
DEPTNO FIRST_NAME LAST_NAME
JOB
RID
---------+---------+---------+---------+---------+---------+---------+
DSNE610I NUMBER OF ROWS DISPLAYED IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+

Step 20: CHECK DATA utility control card (DELETE YES)

pr

Ex

***************************** Top of Data ******


CHECK DATA TABLESPACE WWV8301D.TSDEPT
FOR EXCEPTION IN DEPARTMENT USE EX_DEPARTMENT
IN EMPLOYEE
USE EX_EMPLOYEE
IN PROJECT
USE EX_PROJECT
IN ON_PROJECT USE EX_ON_PROJECT
IN ACTIVITY
USE EX_ACTIVITY
DELETE YES
**************************** Bottom of Data ****

Remark: Table LOCATION is not involved, as LOCATION is neither dependent on nor


descendent from DEPARTMENT.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-65

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1DSNU000I
241 02:11:44.27 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 02:11:44.29 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 02:11:44.30 DSNUGUTC - CHECK DATA TABLESPACE WWV8301D.TSDEPT FOR EXCEPTION IN DEPARTMENT USE
EX_DEPARTMENT IN EMPLOYEE USE EX_EMPLOYEE IN PROJECT USE EX_PROJECT IN ON_PROJECT USE EX_ON_PROJECT IN ACTIVITY USE
EX_ACTIVITY DELETE YES
DSNU726I -DSNB 241 02:11:44.30 DSNUKINP - SCOPE PENDING IS ACTIVE, BUT THE ENTIRE
TABLE SPACE 'WWV8301D.TSDEPT' MUST BE CHECKED
DSNU730I
241 02:11:44.51 DSNUKDST - CHECKING TABLE TSOUB01.DEPARTMENT
DSNU042I
241 02:11:44.56 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=2
ELAPSED TIME=00:00:00
DSNU733I
241 02:11:44.56 DSNUKERK - ROW (RID=X'000000020A') HAS NO PARENT FOR TSOUB01.DEPARTMENT.ED
DSNU733I
241 02:11:44.56 DSNUKERK - ROW (RID=X'000000020B') HAS NO PARENT FOR TSOUB01.DEPARTMENT.DD
DSNU739I
241 02:11:44.56 DSNUKDAT - CHECK TABLE TSOUB01.DEPARTMENT COMPLETE, ELAPSED TIME=00:00:00
DSNU741I -DSNB 241 02:11:44.60 DSNUKRDY - 2 ROWS DELETED FROM TABLE TSOUB01.DEPARTMENT
DSNU741I -DSNB 241 02:11:44.60 DSNUKRDY - 4 ROWS DELETED FROM TABLE TSOUB01.EMPLOYEE
DSNU749I
241 02:11:44.61 DSNUK001 - CHECK DATA COMPLETE,ELAPSED TIME=00:00:00
DSNU010I
241 02:11:44.61 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=4

pr

Step 21: CHECK DATA utility output (DELETE YES)

cl

Ex
Student Exercises

A-66 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Step 22: Verify table space TSDEPT is no longer in check pending


-DIS DB(WWV8301D) SPACE(TS*)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DSNT360I -DSNB ***********************************


DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV8301D STATUS = RW
DBD LENGTH = 20180
DSNT397I -DSNB
NAME
TYPE PART STATUS
PHYERRLO PHYERRHI CATALOG PIECE
-------- ---- ----- ----------------- -------- -------- -------- ----TSDEPT
TS
0001 RW
TSDEPT
TS
RW
TSEMPL
TS
0001 RW
-THRU
0003
TSEMPL
TS
RW
TSEXCEPT TS
RW,AREO*
TSLOCN
TS
RW
TSPROJ
TS
RW
******* DISPLAY OF DATABASE WWV8301D ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
***

As can be seen from the DISPLAY DATABASE command output, table space TSDEPT is
no longer in check pending state.

Table space TSEXCEPT is in advisory REORG-pending (AREO*) state. This means there
are no restrictions to access the data in this table space. However, there may be an impact
on performance until this table space is reorganized. For now, you can ignore this.

Question relating to the CHECK DATA utility:

cl

How many rows has CHECK DATA deleted from table DEPARTMENT,
and why?
Two rows have been deleted by the CHECK DATA utility:

Ex

The DEPARTMENT row with a DEPTNO column value of E31 has been deleted
because it had an invalid MGRNO column value (000101), that is, the foreign key value
violated referential constraint 'ED'.

pr

The DEPARTMENT row with a DEPTNO column value of E41 has been deleted
because it had an invalid SUPERIOR_DEPTNO column value (X01), that is, the foreign
key value violated referential constraint 'DD'.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-67

Student Exercises

Step 23: Read exception tables

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+
SELECT TIME(TIME) AS TIME, DEPTNO, SUPERIOR_DEPTNO, MGRNO,
SUBSTR(NAME, 1, 16) AS NAME, HEX(RID) AS RID
FROM EX_DEPARTMENT;
---------+---------+---------+---------+---------+---------+---------+
TIME
DEPTNO SUPERIOR_DEPTNO MGRNO
NAME
RID
---------+---------+---------+---------+---------+---------+---------+
01.59.07 E31
E01
000101 SOFTWARE SUPP-31 000000020A
01.59.07 E41
X01
000102 SOFTWARE SUPP-41 000000020B
02.11.44 E31
E01
000101 SOFTWARE SUPP-31 000000020A
02.11.44 E41
X01
000102 SOFTWARE SUPP-41 000000020B
DSNE610I NUMBER OF ROWS DISPLAYED IS 4
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+

The first two rows were inserted when the optional steps 16 and 17 were executed
(CHECK DATA utility with DELETE NO) and the last two rows were inserted because of executing
CHECK DATA utility with DELETE YES.

cl

---------+---------+---------+---------+---------+---------+---------+SELECT TIME(TIME) AS TIME, EMPNO, DEPTNO,


SUBSTR(FIRST_NAME, 1, 10) AS FIRST_NAME,
SUBSTR(LAST_NAME, 1, 10) AS LAST_NAME,
SUBSTR(JOB, 1, 10) AS JOB, HEX(RID) AS RID
FROM EX_EMPLOYEE;
---------+---------+---------+---------+---------+---------+---------+TIME
EMPNO
DEPTNO FIRST_NAME LAST_NAME
JOB
RID
---------+---------+---------+---------+---------+---------+---------+02.11.44 000221 E31
BEN
JONES
DESIGNER
0010000208
02.11.44 000222 E31
KATE
JONES
DESIGNER
0010000209
02.11.44 000223 E31
GRACE
JONES
DESIGNER
001000020A
02.11.44 000102 E41
SALLY
JONES
MANAGER
0000000209
DSNE610I NUMBER OF ROWS DISPLAYED IS 4
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+-

Ex

All the four rows were inserted because of executing CHECK DATA utility with DELETE YES.

The deletion of the parent row with a DEPTNO column value of E31 from DEPARTMENT
table caused three dependent rows in the EMPLOYEE table to be deleted.

pr

The deletion of the parent row with a DEPTNO column value of E41 from DEPARTMENT
table caused one dependent row in the EMPLOYEE table to be deleted.

A-68 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Copyright IBM Corp. 1993, 2011


02:33:45.36 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=290
02:33:45.36 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
02:33:45.36 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=870
ELAPSED TIME=00:00:00
241 02:33:45.40 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=290 FOR INDEX TSOUB01.IXPROJ1
241 02:33:45.43 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=290 FOR INDEX TSOUB01.IXPROJ2
241 02:33:45.46 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=290 FOR INDEX TSOUB01.IXPROJ3
02:33:45.47 DSNURBXD - BUILD PHASE STATISTICS - NUMBER OF INDEXES=3
02:33:45.47 DSNURBXD - BUILD PHASE COMPLETE, ELAPSED TIME=00:00:00
241 02:33:45.50 DSNUSUTP - SYSTABLEPART CATALOG UPDATE FOR WWV8301D.TSPROJ SUCCESSFUL
241 02:33:45.50 DSNUSUTB - SYSTABLES CATALOG UPDATE FOR TSOUB01.PROJECT SUCCESSFUL
241 02:33:45.50 DSNUSUTS - SYSTABLESPACE CATALOG UPDATE FOR WWV8301D.TSPROJ SUCCESSFUL
241 02:33:45.50 DSNUSEF2 - RUNSTATS CATALOG TIMESTAMP = 2011-08-29-02.33.45.306533
241 02:33:45.51 DSNURCRI - ENFORCE PHASE STATISTICS RELATIONSHIP TSOUB01.PROJECT.DP
FOREIGN KEYS CHECKED=290
CONSTRAINT VIOLATIONS ENCOUNTERED=0
241 02:33:45.51 DSNURCRI - ENFORCE PHASE STATISTICS RELATIONSHIP TSOUB01.PROJECT.EP
FOREIGN KEYS CHECKED=290
CONSTRAINT VIOLATIONS ENCOUNTERED=0
02:33:45.52 DSNURENF - ENFORCE PHASE COMPLETE, ELAPSED TIME=00:00:00
02:33:45.52 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

02:33:44.34 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


02:33:44.36 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
02:33:44.37 DSNUGUTC - LOAD DATA REPLACE STATISTICS
241 02:33:44.37 DSNURWI - INTO TABLE PROJECT
241 02:33:44.37 DSNURWI (PROJNO POSITION(1:6) CHAR(6),
241 02:33:44.37 DSNURWI DEPTNO POSITION(7:9) CHAR(3),
241 02:33:44.37 DSNURWI EMPNO POSITION(10:15) CHAR(6),
241 02:33:44.37 DSNURWI STAFFING POSITION(17:19) DECIMAL NULLIF(16)=X'FF',
241 02:33:44.37 DSNURWI START_DATE POSITION(21:30) DATE EXTERNAL NULLIF(20)=X'FF',
241 02:33:44.37 DSNURWI END_DATE POSITION(32:41) DATE EXTERNAL NULLIF(31)=X'FF',
241 02:33:44.37 DSNURWI NAME POSITION(42) VARCHAR)
241 02:33:45.30 DSNURRST - EXISTING RECORDS DELETED FROM TABLESPACE
241 02:33:45.35 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=290 FOR TABLE TSOUB01.PROJECT
241 02:33:45.35 DSNURWT - (RE)LOAD PHASE STATISTICS - TOTAL NUMBER OF RECORDS LOADED=290 FOR TABLESPACE

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Answer - To gather inline statistics. This eliminates the need for RUNSTATS after LOAD

Question: What is the purpose of using the keyword STATISTICS in the LOAD utility control statement when loading the PROJECT
table?

241
241

-DSNB

DSNU363I

DSNU369I
DSNU010I

-DSNB
-DSNB
-DSNB
241
241
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB

DSNU349I
DSNU349I
DSNU349I
DSNU258I
DSNU259I
DSNU610I
DSNU610I
DSNU610I
DSNU620I
DSNU363I

1DSNU000I
241
DSNU1044I
241
0DSNU050I
241
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU350I -DSNB
DSNU304I -DSNB
DSNU1147I -DSNB
WWV8301D.TSPROJ
DSNU302I
241
DSNU300I
241
DSNU042I
241

Steps 24 to 27: LOAD utility output for PROJECT table

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-69

241
241
241
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
-DSNB
241

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

02:38:44.01 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


02:38:44.04 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
02:38:44.04 DSNUGUTC - LOAD DATA
241 02:38:44.05 DSNURWI - INTO TABLE ON_PROJECT WHEN(1:1='O')
241 02:38:44.05 DSNURWI (PROJNO POSITION(2:7) CHAR(6),
241 02:38:44.05 DSNURWI EMPNO POSITION(8:13) CHAR(6))
241 02:38:44.05 DSNURWI - INTO TABLE ACTIVITY WHEN(1:1='A')
241 02:38:44.05 DSNURWI (PROJNO POSITION(2:7) CHAR(6),
241 02:38:44.05 DSNURWI EMPNO POSITION(8:13) CHAR(6),
241 02:38:44.05 DSNURWI SEQNO POSITION(14:15) SMALLINT,
241 02:38:44.05 DSNURWI CODE POSITION(16:17) SMALLINT,
241 02:38:44.05 DSNURWI TIME_SPENT POSITION(19:21) DECIMAL NULLIF(18)=X'FF',
241 02:38:44.05 DSNURWI START_DATE POSITION(23:32) DATE EXTERNAL NULLIF(22)=X'FF',
241 02:38:44.05 DSNURWI END_DATE POSITION(34:43) DATE EXTERNAL NULLIF(33)=X'FF')
241 02:38:44.09 DSNURWI - TABLESPACE IS NOT EMPTY
02:38:44.10 DSNUGBAC - UTILITY EXECUTION TERMINATED, HIGHEST RETURN CODE=8

pr

1DSNU000I
DSNU1044I
0DSNU050I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU650I
DSNU330I
DSNU012I

Steps 28 to 30: LOAD utility output for ON_PROJECT and ACTIVITY tables (RESUME NO by default)

cl

Ex
Student Exercises

A-70 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Step 31: Why did the load of ON_PROJECT and ACTIVITY fail?

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

The utility control statement specified (by default) RESUME NO, which means that the
utility assumes that the table space is empty. If the table space is not empty and the control
statement does not specify REPLACE, the utility terminates with return code 8.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-71

A-72 DB2 10 for z/OS DB Admin Workshop Part 1

-DSNB

DSNU363I

241
241

-DSNB

DSNU363I

DSNU369I
DSNU010I

-DSNB
-DSNB
-DSNB
-DSNB
241
241
-DSNB

DSNU349I
DSNU349I
DSNU349I
DSNU349I
DSNU258I
DSNU259I
DSNU363I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

02:42:32.66 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=113


02:42:32.66 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
02:42:32.67 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=339
ELAPSED TIME=00:00:00
241 02:42:32.70 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=39 FOR INDEX TSOUB01.IXONPR1
241 02:42:32.74 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=74 FOR INDEX TSOUB01.IXACTY1
241 02:42:32.77 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=74 FOR INDEX TSOUB01.IXACTY2
241 02:42:32.80 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=39 FOR INDEX TSOUB01.IXONPR2
02:42:32.80 DSNURBXD - BUILD PHASE STATISTICS - NUMBER OF INDEXES=4
02:42:32.80 DSNURBXD - BUILD PHASE COMPLETE, ELAPSED TIME=00:00:00
241 02:42:32.84 DSNURCRI - ENFORCE PHASE STATISTICS RELATIONSHIP TSOUB01.ON_PROJECT.EO
FOREIGN KEYS CHECKED=39
CONSTRAINT VIOLATIONS ENCOUNTERED=0
241 02:42:32.84 DSNURCRI - ENFORCE PHASE STATISTICS RELATIONSHIP TSOUB01.ON_PROJECT.PO
FOREIGN KEYS CHECKED=39
CONSTRAINT VIOLATIONS ENCOUNTERED=0
241 02:42:32.84 DSNURCRI - ENFORCE PHASE STATISTICS RELATIONSHIP TSOUB01.ACTIVITY.OA
FOREIGN KEYS CHECKED=74
CONSTRAINT VIOLATIONS ENCOUNTERED=0
02:42:32.85 DSNURENF - ENFORCE PHASE COMPLETE, ELAPSED TIME=00:00:00
02:42:32.86 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

02:42:32.53 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


02:42:32.55 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
02:42:32.56 DSNUGUTC - LOAD DATA RESUME YES
241 02:42:32.56 DSNURWI - INTO TABLE ON_PROJECT WHEN(1:1='O')
241 02:42:32.56 DSNURWI (PROJNO POSITION(2:7) CHAR(6),
241 02:42:32.56 DSNURWI EMPNO POSITION(8:13) CHAR(6))
241 02:42:32.56 DSNURWI - INTO TABLE ACTIVITY WHEN(1:1='A')
241 02:42:32.56 DSNURWI (PROJNO POSITION(2:7) CHAR(6),
241 02:42:32.56 DSNURWI EMPNO POSITION(8:13) CHAR(6),
241 02:42:32.56 DSNURWI SEQNO POSITION(14:15) SMALLINT,
241 02:42:32.56 DSNURWI CODE POSITION(16:17) SMALLINT,
241 02:42:32.56 DSNURWI TIME_SPENT POSITION(19:21) DECIMAL NULLIF(18)=X'FF',
241 02:42:32.56 DSNURWI START_DATE POSITION(23:32) DATE EXTERNAL NULLIF(22)=X'FF',
241 02:42:32.56 DSNURWI END_DATE POSITION(34:43) DATE EXTERNAL NULLIF(33)=X'FF')
241 02:42:32.66 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=39 FOR TABLE TSOUB01.ON_PROJECT
241 02:42:32.66 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=74 FOR TABLE TSOUB01.ACTIVITY
241 02:42:32.66 DSNURWT - (RE)LOAD PHASE STATISTICS - TOTAL NUMBER OF RECORDS LOADED=113 FOR TABLESPACE

pr

1DSNU000I
241
DSNU1044I
241
0DSNU050I
241
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU650I -DSNB
DSNU304I -DSNB
DSNU304I -DSNB
DSNU1147I -DSNB
WWV8301D.TSPROJ
DSNU302I
241
DSNU300I
241
DSNU042I
241

Steps 31 to 33: LOAD utility output for ON_PROJECT and ACTIVITY tables (RESUME YES)

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Step 33: Questions relating to load of ON_PROJECT and ACTIVITY


tables
a. Can the REPLACE option of the LOAD utility be used to replace the existing
data for the ON_PROJECT and ACTIVITY tables while preserving the data for
the PROJECT table?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

No, the REPLACE option applies to all data in a table space or partition.

b. How was the use of REPLACE option appropriate when the PROJECT table
data was loaded?

The REPLACE option was appropriate because the table space was empty. The
reason for using the REPLACE option is that, in conjunction with STATISTICS,
statistics are gathered in the catalog tables, including the real-time statistics tables.

c. Assuming you have reset the ACTIVITY table, can you repeat steps 28 to 30 to
load the ON_PROJECT and ACTIVITY tables?

pr

Ex

cl

You cannot do this unless you get rid of the data from ON_PROJECT table first by
issuing a mass DELETE statement DELETE FROM ON_PROJECT. Of course you
can do a LOAD RESUME YES of only the ACTIVITY table and there is no need to
get rid of the data from ON_PROJECT table.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-73

Student Exercises

Step 34: Create partition by growth universal table space

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE TABLESPACE TSNEWDEP


IN WWV8301D
DSSIZE 1 G
MAXPARTITIONS 5
FREEPAGE 1
PCTFREE 99;
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+
CREATE TABLE NEWDEPT LIKE DEPARTMENT
IN WWV8301D.TSNEWDEP;
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

Step 35: Gather information from catalog tables

pr

Ex

cl

SELECT SUBSTR(NAME,1,10) AS NAME,


SUBSTR(CREATOR,1,15) AS CREATOR,
SUBSTR(DBNAME,1,15) AS DBNAME,
TYPE,MAXPARTITIONS
FROM SYSIBM.SYSTABLESPACE
WHERE NAME = 'TSNEWDEP' AND CREATOR=USER
WITH UR ;
---------+---------+---------+---------+---------+---------+-----NAME
CREATOR
DBNAME
TYPE MAXPARTITIONS
---------+---------+---------+---------+---------+---------+-----TSNEWDEP
TSOUB01
WWV8301D
G
5
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
SELECT PARTITION,
SUBSTR(TSNAME,1,15) AS TSNAME,
SUBSTR(DBNAME,1,15) AS DBNAME
FROM SYSIBM.SYSTABLEPART
WHERE TSNAME = 'TSNEWDEP' AND DBNAME='WWV8301D'
WITH UR ;
---------+---------+---------+---------+---------+---PARTITION TSNAME
DBNAME
---------+---------+---------+---------+---------+---1 TSNEWDEP
WWV8301D
DSNE610I NUMBER OF ROWS DISPLAYED IS 1

A-74 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 36: How many partitions are created?


Notice TYPE is G in SYSIBM.SYSTABLESPACE and PARTITION is 1 in
SYSIBM.SYSTABLEPART indicating a partition by growth universal table space with one
partition has been created.
ISPF 3.4 confirms this:

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DBDSNB.DSNBBC.WWV8301D.TSNEWDEP.I0001.A001
DBDSNB.DSNBBD.WWV8301D.TSNEWDEP.I0001.A001

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-75

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1DSNU000I
241 03:00:17.95 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 03:00:17.98 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 03:00:17.98 DSNUGUTC - LOAD DATA LOG NO
DSNU650I -DSNB 241 03:00:17.98 DSNURWI - INTO TABLE NEWDEPT
DSNU650I -DSNB 241 03:00:17.98 DSNURWI (DEPTNO POSITION(1:3) CHAR(3),
DSNU650I -DSNB 241 03:00:17.98 DSNURWI SUPERIOR_DEPTNO POSITION(5:7) CHAR(3) NULLIF(4)=X'FF',
DSNU650I -DSNB 241 03:00:17.98 DSNURWI MGRNO POSITION(9:14) CHAR(6) NULLIF(8)=X'FF',
DSNU650I -DSNB 241 03:00:17.98 DSNURWI NAME POSITION(15) VARCHAR)
DSNU304I -DSNB 241 03:00:38.06 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=150003 FOR TABLE
TSOUB01.NEWDEPT
DSNU1147I -DSNB 241 03:00:38.06 DSNURWT - (RE)LOAD PHASE STATISTICS - TOTAL NUMBER OF RECORDS LOADED=150003 FOR
TABLESPACE WWV8301D.TSNEWDEP
DSNU302I
241 03:00:38.06 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=150003
DSNU300I
241 03:00:38.06 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:20
DSNU380I -DSNB 241 03:00:38.06 DSNUGSRX - TABLESPACE WWV8301D.TSNEWDEP PARTITION 1 IS IN COPY PENDING
DSNU380I -DSNB 241 03:00:38.06 DSNUGSRX - TABLESPACE WWV8301D.TSNEWDEP PARTITION 2 IS IN COPY PENDING
DSNU010I
241 03:00:38.06 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=4

pr

Step 37: LOAD table space TSNEWDEP

cl

Ex
Student Exercises

A-76 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Step 38: How many partitions do you see after the LOAD utility
completes?
Note we started with one partition and after successful completion of LOAD utility, two
partitions are placed in copy pending (because of LOG NO).

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

ISPF 3.4 confirms the partition by growth universal table space has now grown to 2
partitions:
DBDSNB.DSNBBC.WWV8301D.TSNEWDEP.I0001.A001
DBDSNB.DSNBBC.WWV8301D.TSNEWDEP.I0001.A002
DBDSNB.DSNBBD.WWV8301D.TSNEWDEP.I0001.A001
DBDSNB.DSNBBD.WWV8301D.TSNEWDEP.I0001.A002

Step 39: Drop the partition by growth universal table space

pr

Ex

cl

DROP TABLESPACE WWV8301D.TSNEWDEP;


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-77

Student Exercises

Step 40: UNLOAD table space TSPROJ


TSOUB01.DSNUUNL.CNTL

Columns 00001 00072

//

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

//TSOUB011 JOB 1CV83G26,'TSOUB01 JOB


',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=TSOUB01,REGION=0M
//*
//*
//UTIL EXEC DSNBUPRC,SYSTEM=DSNB,UID='TSOUB01',UTPROC=''
//*
//**********************************************
//*
//* GENERATING JCL FOR THE UNLOAD UTILITY
//* DATE: 08/29/11
TIME: 03:26:31
//*
//**********************************************
//*
//DSNUPROC.SYSREC DD DSN=TSOUB01.CV83.TSPROJ.UNLOAD.DATA,
//
DISP=(MOD,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSPUNCH DD DSN=TSOUB01.CV83.TSPROJ.UNLOAD.PUNCH,
//
DISP=(MOD,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSIN
DD *
UNLOAD TABLESPACE WWV8301D.TSPROJ

Job output:

pr

Ex

cl

1DSNU000I
241 03:26:38.92 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 03:26:38.95 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 03:26:38.95 DSNUGUTC - UNLOAD TABLESPACE WWV8301D.TSPROJ
DSNU253I
241 03:26:38.99 DSNUUNLD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS
UNLOADED=290 FOR TABLE TSOUB01.PROJECT
DSNU253I
241 03:26:38.99 DSNUUNLD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS
UNLOADED=39 FOR TABLE TSOUB01.ON_PROJECT
DSNU253I
241 03:26:38.99 DSNUUNLD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS
UNLOADED=74 FOR TABLE TSOUB01.ACTIVITY
DSNU252I
241 03:26:38.99 DSNUUNLD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS
UNLOADED=403 FOR TABLESPACE WWV8301D.TSPROJ
DSNU250I
241 03:26:38.99 DSNUUNLD - UNLOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
241 03:26:39.00 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

A-78 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

Generated LOAD statement:


TSOUB01.CV83.TSPROJ.UNLOAD.PUNCH
===>
LOAD DATA INDDN SYSREC
LOG NO RESUME YES
EBCDIC CCSID(00037,00000,00000)
INTO TABLE "TSOUB01"."PROJECT"
WHEN(00001:00002) = X'000B'
NUMRECS
290
( "PROJNO"
POSITION( 00003:00008) CHAR(00006)
, "DEPTNO"
POSITION( 00009:00011) CHAR(00003)
, "EMPNO"
POSITION( 00012:00017) CHAR(00006)
, "STAFFING"
POSITION( 00019:00021) DECIMAL
NULLIF(00018)=X'FF'
, "START_DATE"
POSITION( 00023:00032) DATE EXTERNAL
NULLIF(00022)=X'FF'
, "END_DATE"
POSITION( 00034:00043) DATE EXTERNAL
NULLIF(00033)=X'FF'
, "NAME"
POSITION( 00044:00095) VARCHAR
)
INTO TABLE "TSOUB01"."ON_PROJECT"
WHEN(00001:00002) = X'000C'
NUMRECS
39
( "PROJNO"
POSITION( 00003:00008) CHAR(00006)
, "EMPNO"
POSITION( 00009:00014) CHAR(00006)
)
INTO TABLE "TSOUB01"."ACTIVITY"
WHEN(00001:00002) = X'000D'
NUMRECS
74
( "PROJNO"
POSITION( 00003:00008) CHAR(00006)
, "EMPNO"
POSITION( 00009:00014) CHAR(00006)
, "SEQNO"
POSITION( 00015:00016) SMALLINT
, "CODE"
POSITION( 00017:00018) SMALLINT
, "TIME_SPENT"
POSITION( 00020:00022) DECIMAL
NULLIF(00019)=X'FF'
, "START_DATE"
POSITION( 00024:00033) DATE EXTERNAL
NULLIF(00023)=X'FF'
, "END_DATE"
POSITION( 00035:00044) DATE EXTERNAL
NULLIF(00034)=X'FF'
)

Columns 00001 00072


Scroll ===> CSR

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-79

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

BROWSE
TSOUB01.CV83.TSPROJ.UNLOAD.DATA
Line 00000000 Col 001 080
Command ===>
Scroll ===> CSR
******************************** Top of Data **********************************
..AD3100D01000010....1982-01-01.1983-02-01..ADMIN SERVICES
..MA2100D01000010.....1982-01-01.1983-02-01..WELD LINE AUTOMATION
..PL2100B01000020.....1982-01-01.1982-09-15..WELD LINE PLANNING ...
...etc
...
..AD3100000010
..MA2100000010
..MA2110000010
..PL2100000020
...
...etc
...
..AD3100000010.........1982-01-01.1982-07-01
..AD3110000070.........1982-01-01.1983-02-01
..AD3111000230.........1982-01-01.1982-03-15
..AD3111000230.........1982-03-15.1982-04-15
...
...etc
...

pr

Step 40: UNLOADed data (table space TSPROJ with 3 tables)

cl

Ex
Student Exercises

A-80 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Copyright IBM Corp. 1993, 2011

This explains the WHEN options in the previous control statement.

Remark:
If you set hex on, you see the that OBID of the table is unloaded first:
here 000B for PROJECT
(similar: 000C for ON_PROJECT, 000D for ACTIVITY)

-----------------------------------------------------------------------------000001
AD3100D01000010 01/01/1982 02/01/1983 ADMIN SERVICES
00CCFFFFCFFFFFFFF00600FF4FF4FFFF0FF4FF4FFFF00CCDCD4ECDECCCE4444444444444
0B143100401000010005C001B01B1982001B02B19830E144950259593520000000000000
-----------------------------------------------------------------------------000002
MA2100D01000010
01/01/1982 02/01/1983 WELD LINE AUTOMATION
00DCFFFFCFFFFFFFF00200FF4FF4FFFF0FF4FF4FFFF01ECDC4DCDC4CEEDDCECDD4444444
0B412100401000010010C001B01B1982001B02B198304653403955014364139650000000
-----------------------------------------------------------------------------000003
PL2100B01000020
01/01/1982 09/15/1982 WELD LINE PLANNING
00DDFFFFCFFFFFFFF00100FF4FF4FFFF0FF4FF4FFFF01ECDC4DCDC4DDCDDCDC444444444
0B732100201000020000C001B01B1982015B09B198202653403955073155957000000000
------------------------------------------------------------------------------

EDIT
TSOUB01.CV83.TSPROJ.UNLOAD.DATA
Columns 00001 00072
Command ===> hex on
Scroll ===> CSR
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-****** ***************************** Top of Data ******************************

Step 40: UNLOADed data in hex

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-81

Student Exercises

Step 41: UNLOAD DELIMITED


If you try to unload the whole tablespace, the UNLOAD fails with the message:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

********************************* TOP OF DATA **********************************


1DSNU000I
241 05:16:28.97 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUDB01
DSNU1044I
241 05:16:29.00 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 05:16:29.00 DSNUGUTC - UNLOAD TABLESPACE WWV8301D.TSPROJ DELIMITED
DSNU1254I -DSNB 241 05:16:29.00 DSNUULIA - FORMAT DELIMITED REQUIRES ONE AND ONLY ONE FROM
TABLE
DSNU012I
241 05:16:29.01 DSNUGBAC - UTILITY EXECUTION TERMINATED, HIGHEST RETURN CODE=8
******************************** BOTTOM OF DATA ********************************

pr

Ex

cl

Therefore, unload table PROJECT only.

A-82 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1DSNU000I
241
DSNU1044I
241
0DSNU050I
241
DSNU650I -DSNB
DSNU253I
241
TSOUB01.PROJECT
DSNU252I
241
WWV8301D.TSPROJ
DSNU250I
241
DSNU010I
241
05:27:12.97 DSNUUNLD - UNLOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
05:27:12.98 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

05:27:12.97 DSNUUNLD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS UNLOADED=290 FOR TABLESPACE

05:27:12.92 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUDB01


05:27:12.95 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
05:27:12.95 DSNUGUTC - UNLOAD TABLESPACE WWV8301D.TSPROJ DELIMITED
241 05:27:12.95 DSNUUGMS FROM TABLE PROJECT
05:27:12.97 DSNUUNLD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS UNLOADED=290 FOR TABLE

Step 41: Unload PROJECT table in delimited format (job output)

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-83

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

A-84 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Note: With delimited, the OBID is not unloaded at the beginning of the record.

"AD3230","D21","000270",2.00,1982-01-01,1983-02-01,"ACCOUNT.PROGRAMMING"
"OP2011","E21","000320",1.00,1982-01-01,1983-02-01,"SCP SYSTEMS SUPPORT"
"OP2012","E21","000330",1.00,1982-01-01,1983-02-01,"APPLICATIONS SUPPORT"
"OP2013","E21","000340",1.00,1982-01-01,1983-02-01,"DB/DC SUPPORT"

"OP2063","E21","000100",4.00,1982-01-01,1983-02-01,"SYSTEMS SUPPORT"
"MA2112","D11","000150",3.00,1982-01-01,1982-12-01,"W L ROBOT DESIGN"
"MA2113","D11","000160",3.00,1982-02-15,1982-12-01,"W L PROD CONT PROGS"
"MA2111","D11","000220",2.00,1982-01-01,1982-12-01,"W L PROGRAM DESIGN"
"AD3111","D21","000230",2.00,1982-01-01,1983-02-01,"PAYROLL PROGRAMMING"
"AD3112","D21","000250",1.00,1982-01-01,1983-02-01,"PERSONNEL PROGRAMMG"
"AD3113","D21","000270",2.00,1982-01-01,1983-02-01,"ACCOUNT.PROGRAMMING"
..........................................................................
..........................................................................
..........................................................................

"MA2163","D11","000060",9.00,1982-01-01,1983-02-01,"W L PROGRAMMING"
"AD3110","D21","000070",6.00,1982-01-01,1983-02-01,"GENERAL AD SYSTEMS"
"OP1010","E11","000090",5.00,1982-01-01,1983-02-01,"OPERATION"
"OP2010","E21","000100",4.00,1982-01-01,1983-02-01,"SYSTEMS SUPPORT"
..........................................................................
..........................................................................
..........................................................................

..........................................................................
..........................................................................
..........................................................................

"PL2240","B01","000020",1.00,1982-01-01,1982-09-15,"WELD LINE PLANNING"


"IF1000","C01","000030",2.00,1982-01-01,1983-02-01,"QUERY SERVICES"
"IF2000","C01","000030",1.00,1982-01-01,1983-02-01,"USER EDUCATION"
"OP1000","E01","000050",6.00,1982-01-01,1983-02-01,"OPERATION SUPPORT"
"OP2000","E01","000050",5.00,1982-01-01,1983-02-01,"GEN SYSTEMS SERVICES"
"MA2110","D11","000060",9.00,1982-01-01,1983-02-01,"W L PROGRAMMING"

"AD3100","D01","000010",6.50,1982-01-01,1983-02-01,"ADMIN SERVICES"
"MA2100","D01","000010",12.00,1982-01-01,1983-02-01,"WELD LINE AUTOMATION"
"PL2100","B01","000020",1.00,1982-01-01,1982-09-15,"WELD LINE PLANNING"
..........................................................................
..........................................................................
..........................................................................

pr

Step 41: PROJECT table data unloaded in delimited format by UNLOAD utility

cl

Ex
Student Exercises

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

LOAD DATA INDDN SYSREC


LOG NO RESUME YES
EBCDIC CCSID(00037,00000,00000)
FORMAT DELIMITED COLDEL X'6B' CHARDEL X'7F'
INTO TABLE
"TSOUB01".
"PROJECT"
NUMRECS
290
( "PROJNO"
POSITION(*)
CHAR(00006)
, "DEPTNO"
POSITION(*)
CHAR(00003)
, "EMPNO"
POSITION(*)
CHAR(00006)
, "STAFFING"
POSITION(*)
DECIMAL
, "START_DATE"
POSITION(*)
DATE EXTERNAL
, "END_DATE"
POSITION(*)
DATE EXTERNAL
, "NAME"
POSITION(*)
VARCHAR
)
DECPT

X'4B'

Step 41: LOAD utility control statement generated by UNLOAD utility

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-85

Student Exercises

Step 42: Unloading from a view via DSNTIAUL

Step 42a: Creating a view to unload from:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+
CREATE VIEW VDEPMGR AS
(SELECT E1.EMPNO, SUBSTR(E1.LAST_NAME,1,10) AS LAST_NAME,
E1.DEPTNO,
D.MGRNO, SUBSTR(E2.LAST_NAME,1,10) AS MGRNAME
FROM EMPLOYEE E1
INNER JOIN DEPARTMENT D
ON E1.DEPTNO = D.DEPTNO
INNER JOIN EMPLOYEE E2
ON D.MGRNO = E2.EMPNO) ;
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+

View result:

---------+---------+---------+---------+----SELECT * FROM VDEPMGR ;


---------+---------+---------+---------+----EMPNO
LAST_NAME
DEPTNO MGRNO
MGRNAME
---------+---------+---------+---------+----000010 HAAS
A00
000010 HAAS
000110 LUCCHESI
A00
000010 HAAS
000120 O'CONNELL
A00
000010 HAAS
000020 THOMPSON
B01
000020 THOMPSON
000130 QUINTANA
C01
000030 KWAN
000140 NICHOLLS
C01
000030 KWAN

cl

... and so on.

pr

Ex

000320 MEHTA
E21
000100 SPENSER
000330 LEE
E21
000100 SPENSER
000340 GOUNOT
E21
000100 SPENSER
DSNE610I NUMBER OF ROWS DISPLAYED IS 32
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+

A-86 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 42b: DSNTIAUL job

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.CNTL(L6TIAUL) - 01.02
===>
***************************** Top of Data ***********************
//TSOUB011 JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=&SYSUID,REGION=0M
//*******************************************************************
//*
*
//*******************************************************************
//DSNTIAUL EXEC PGM=IKJEFT01,DYNAMNBR=20
//STEPLIB DD DSN=DBDSNB.DB2A10.SDSNEXIT,DISP=SHR
//
DD DSN=DBDSNB.DB2A10.SDSNLOAD,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DSNB)
RUN PROGRAM(DSNTIAUL) PLAN(DSNTIB10) PARMS('SQL,10') LIB('DBDSNB.DB2A10.RUNLIB.LOAD')
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSREC00 DD DSN=&SYSUID..CV83.DSNTIAUL.SELECT00,
//
UNIT=SYSDA,SPACE=(32760,(20,20)),DISP=(,CATLG)
//SYSREC01 DD DSN=&SYSUID..CV83.DSNTIAUL.SELECT01,
//
UNIT=SYSDA,SPACE=(32760,(20,20)),DISP=(,CATLG)
//SYSPUNCH DD DSN=&SYSUID..CV83.DSNTIAUL.PUNCH,
//
UNIT=SYSDA,SPACE=(800,(15,15)),DISP=(,CATLG),
//
RECFM=FB,LRECL=120,BLKSIZE=1200
//SYSIN
DD *
SELECT * FROM TSOUB01.VDEPMGR ;
SELECT * FROM TSOUB01.LOCATION L, TSOUB01.EMPLOYEE E
WHERE E.LOCID = L.LOCID
ORDER BY L.LOCID ;
**************************** Bottom of Data *********************

cl

Job output:

pr

Ex

********************************* TOP OF DATA **************************


DSNT490I SAMPLE DATA UNLOAD PROGRAM
DSNT505I DSNTIAUL OPTIONS USED: SQL,10
DSNT503I UNLOAD DATA SET SYSREC00 RECORD LENGTH SET TO
37
DSNT504I UNLOAD DATA SET SYSREC00 BLOCK SIZE SET TO 27972
DSNT495I SUCCESSFUL UNLOAD
32 ROWS OF TABLE TSOUB01.VDEPMGR
DSNT503I UNLOAD DATA SET SYSREC01 RECORD LENGTH SET TO
279
DSNT504I UNLOAD DATA SET SYSREC01 BLOCK SIZE SET TO 27900
DSNT495I SUCCESSFUL UNLOAD
29 ROWS OF TABLE TSOUB01.LOCATION
******************************** BOTTOM OF DATA ************************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-87

Student Exercises

Step 42c: Inspect the output


Output of the first query:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.DSNTIAUL.SELECT00
===>
***************************** Top of Data *****
000010HAAS
A00 000010 HAAS
000110LUCCHESI A00 000010 HAAS
000120O'CONNELL A00 000010 HAAS
000020THOMPSON B01 000020 THOMPSON
000130QUINTANA C01 000030 KWAN
000140NICHOLLS C01 000030 KWAN
........
**************************** Bottom of Data ***

Output of the second query:

pr

Ex

cl

TSOUB01.CV83.DSNTIAUL.SELECT01
...
===>
...
***************************** Top of Data **********...
DE71083-01AM FICHTENBERG 1
HERRENBERG ...
DE71083-01AM FICHTENBERG 1
HERRENBERG ...
DE71083-01AM FICHTENBERG 1
HERRENBERG ...
DE71083-01AM FICHTENBERG 1
HERRENBERG ...
US95141-B4555 BAILEY AVENUE
SAN JOSE
...
US95141-B4555 BAILEY AVENUE
SAN JOSE
...
US95141-B4555 BAILEY AVENUE
SAN JOSE
...
US95141-B4555 BAILEY AVENUE
SAN JOSE
...
..........
...
**************************** Bottom of Data ********...

A-88 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

Punch data set output


TSOUB01.CV83.DSNTIAUL.PUNCH
===>
***************************** Top of Data ****************************
LOAD DATA LOG NO INDDN SYSREC00 INTO TABLE
TSOUB01.VDEPMGR
(
EMPNO
POSITION(
1
)
CHAR(
6) ,
LAST_NAME
POSITION(
7
)
CHAR(
10) ,
DEPTNO
POSITION(
17
)
CHAR(
3)
NULLIF(
20)='?',
MGRNO
POSITION(
21
)
CHAR(
6)
NULLIF(
27)='?',
MGRNAME
POSITION(
28
)
CHAR(
10)
)
LOAD DATA LOG NO INDDN SYSREC01 INTO TABLE
TSOUB01.LOCATION
(
LOCID
POSITION(
1
)
CHAR(
10) ,
ADDRESS
POSITION(
11
)
CHAR(
30) ,
CITY
POSITION(
41
)
CHAR(
30) ,
POSTAL_CODE
POSITION(
71
)
CHAR(
15) ,
COUNTRY
POSITION(
86
)
CHAR(
30) ,
EMPNO
POSITION(
116
)
CHAR(
6) ,
FIRST_NAME
POSITION(
122
)
CHAR(
20) ,
MIDDLE_INITIAL
POSITION(
142
)
CHAR(
1)
NULLIF(
143)='?',
SEX
POSITION(
144
)
CHAR(
1) ,
BIRTHDATE
POSITION(
145
)
DATE EXTERNAL(
10)
NULLIF(
155)='?',
.........
**************************** Bottom of Data **************************

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

The generated LOAD statements need modifications: Loading into a R/O view or loading
employee fields into the LOCATION table are not possible.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-89

Student Exercises

Step 43: DSN1PRNT


As can be derived from the following DSN1PRNT job and output:
a. //SYSUT1 DD DSN=DBDSNB.DSNDBC.WWV8301D.TSDEPT.I0001.A001,DISP=SHR
b. PARM='PRINT(0,2),EBCDIC,FORMAT is ok;

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

but solution with PARM='PRINT(0,F),EBCDIC,FORMAT - to demonstrate hex number


c. 3 pages are printed: Header page, spacemap page, and one data page.
d. ID MAP has 11 entries.
e. 4 holes

f. 2 holes derive from LOAD department; 2 rows deleted because of unique index
violation.
2 holes derived from CHECK DATA; 2 rows deleted because of RI violations.
Note

For universal table spaces, prior to Version 10 NFM, holes consist of free space in a data
page and occur when a record is deleted. In Version 10 NFM, DB2 does not mark and
chain the pseudo deleted row as a hole, so that the content remains available to read
transactions with currently committed semantic. The four PD-REC records you see in
Page 2 of DSN1PRNT output are for the 4 rows deleted.

g. There is only one table in TSDEPT: SELECT COUNT(*) FROM DEPARTMENT yields 9.

h. OBID of the table: PGSOBD='000A'X. This equals the information in the DB2 catalog:

Ex

cl

---------+---------+---------+---------+---------+---------+---------+-----SELECT OBID, NAME, CREATOR, TYPE, DBNAME


FROM SYSIBM.SYSTABLES
WHERE CREATOR = USER AND TSNAME = 'TSDEPT'
WITH UR ;
---------+---------+---------+---------+---------+---------+
OBID NAME
CREATOR
TYPE DBNAME
---------+---------+---------+---------+---------+---------+
10 DEPARTMENT
TSOUB01
T
WWV8301D
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
---------+---------+---------+---------+---------+---------+---------+------

Length of first row: PGSLTH=50, length of second row: PGSLTH=30. Different, as


one column is defined as VARCHAR(50).

pr

i.

j.

Insert of a row with maximal length, which is 66 according to the DB2 catalog, table
SYSIBM.SYSCOLUMNS (taking into account a 2-byte length field and 2 Null
Indicators). After stop and start TSDEPT, the new DSN1PRNT output (not depicted)
for this new row is 72. Reason: Each record has a 6-byte header.

A-90 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

DSN1PRNT job

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.CNTL(L6PRINT) - 01.00
Columns 00001 00072
===>
Scroll ===> CSR
//TSOUB011 JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=&SYSUID,REGION=0M
//*******************************************************************
//*
*
//*******************************************************************
//STEP1
EXEC PGM=DSN1PRNT,PARM='PRINT(0,2),EBCDIC,FORMAT'
//STEPLIB DD DSN=DBDSNB.DB2A10.SDSNEXIT,DISP=SHR
//
DD DSN=DBDSNB.DB2A10.SDSNLOAD,DISP=SHR
//SYSUT1
DD DSN=DBDSNB.DSNDBC.WWV8301D.TSDEPT.I0001.A001,DISP=SHR
//SYSPRINT DD SYSOUT=*
**************************** Bottom of Data ****************************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-91

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.
/

A-92 DB2 10 for z/OS DB Admin Workshop Part 1

SECOND PART OF SEGMENTED SPACE MAP:


RELPG 00
20
40
60
0000
C0000000
80

A0

C0

E0

PAGE: # 00000001
---------------------------------------------------------------------------------------------------------------SEGMENTED SPACEMAP PAGE: PGCOMB='10'X PGLOGRBA='0000059A7752'X PGNUM='00000001'X PGFLAGS='30'X
SEGNUM='0096'X SEGFREE='0095'X SEGENT='0002'X SEGSIZE='0020'X
SEGLENT='00000001'X FOEND='N'
FIRST PART OF SEGMENTED SPACE MAP:
SEG 0001
00000000000AC0 30000000000000000000000000000000

PAGE: # 00000000
---------------------------------------------------------------------------------------------------------------HEADER PAGE: PGCOMB='00'X PGLOGRBA='0000059A6BD0'X PGNUM='00000000'X PGFLAGS='38'X
HPGOBID='011A0004'X HPGHPREF='000000B4'X HPGCATRL='00'X HPGREL='D6'X HPGZLD='00'X
HPGCATV='00'X HPGTORBA='000000000000'X HPGTSTMP='20110826021818230026'X
HPGSSNM='DSNB' HPGFOID='0003'X HPGPGSZ='1000'X HPGSGSZ='0020'X HPGPARTN='0001'X
HPGZ3PNO='000000'X HPGZNUMP='00'X HPGTBLC='0001'X HPGROID='000A'X
HPGZ4PNO='00000000'X HPGMAXL='0042'X HPGNUMCO='0004'X HPGFLAGS='010A'X
HPGFLAGS2='00'X HPGCONTM='20110826021840973762'X HPGSGNAM='WWV8301S'
HPGVCATN='DBDSNB ' HPGRBRBA='0000060B3D96'X HPGLEVEL='0000060B3D96'X
HPGPLEVL='0000059D4000'X HPGCLRSN='0000054A0C2C'X HPGSCCSI='0025'X HPGDCCSI='0000'X
HPGMCCSI='0000'X HPGDSSZ='00400000'X HPGFLAG2='00'X HPGEPOCH='0000'X
HPGRBLP='000000000000'X HPGMASSDELETETIMESTAMP='000000000000'X HPGDNUMB='01'X
HPGDNUMC='0100'X HPGDFSG='00000000'X HPGDLSG='00000000'X HPGSISP='00000000'X
FOEND='E'
SI HASH BUCKET: HPGDBKT#='01'X HPGS1BEYE='E2'X HPGS1OBI='000A'X HPGS1FSG='00000001'X
HPGS1CSG='00000001'X HPGS1LSG='00000001'X

1DSN1999I START OF DSN1PRNT FOR JOB TSOUB011 STEP1


DSN1989I DSN1PRNT IS PROCESSED WITH THE FOLLOWING OPTIONS:
4K/NO IMAGECOPY/NUMPARTS =
0/
FORMAT/NO EXPAND/
PRINT/NO VALUE/
DSSIZE=
/PIECESIZ=
/EBCDIC /
DSN1998I INPUT DSNAME = DBDSNB.DSNDBC.WWV8301D.TSDEPT.I0001.A001
, VSAM

pr

Step 43: DSN1PRNT output, part 1 of 2

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Copyright IBM Corp. 1993, 2011


PGSOBD='0000'X PGSBID='02'X
B01.A00.000020..PLANNING

PGSOBD='0000'X PGSBID='08'X
E11.E01.000090..OPERATIONS

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

0DSN1994I DSN1PRNT COMPLETED SUCCESSFULLY,

00000003 PAGES PROCESSED

PD-REC: XOFFSET='01E9'X PGSFLAGS='02'X PGSLTH=38 PGSLTH='0026'X PGSOBD='0000'X PGSBID='0D'X


C5F5F100 C5F0F100 F0F0F0F1 F0F40010 E2D6C6E3 E6C1D9C5 40E2E4D7 D760F6F1
E51.E01.000104..SOFTWARE SUPP-61

PD-REC: XOFFSET='01C3'X PGSFLAGS='02'X PGSLTH=38 PGSLTH='0026'X PGSOBD='0000'X PGSBID='0C'X


C5F5F100 C5F0F100 F0F0F0F1 F0F30010 E2D6C6E3 E6C1D9C5 40E2E4D7 D760F5F1
E51.E01.000103..SOFTWARE SUPP-51

PD-REC: XOFFSET='019D'X PGSFLAGS='02'X PGSLTH=38 PGSLTH='0026'X PGSOBD='0000'X PGSBID='0B'X


C5F4F100 E7F0F100 F0F0F0F1 F0F20010 E2D6C6E3 E6C1D9C5 40E2E4D7 D760F4F1
E41.X01.000102..SOFTWARE SUPP-41

PD-REC: XOFFSET='0177'X PGSFLAGS='02'X PGSLTH=38 PGSLTH='0026'X PGSOBD='0000'X PGSBID='0A'X


C5F3F100 C5F0F100 F0F0F0F1 F0F10010 E2D6C6E3 E6C1D9C5 40E2E4D7 D760F3F1
E31.E01.000101..SOFTWARE SUPP-31

RECORD: XOFFSET='0151'X PGSFLAGS='00'X PGSLTH=38 PGSLTH='0026'X PGSOBD='0000'X PGSBID='09'X


C5F2F100 C5F0F100 F0F0F0F1 F0F00010 E2D6C6E3 E6C1D9C5 40E2E4D7 D7D6D9E3
E21.E01.000100..SOFTWARE SUPPORT

RECORD: XOFFSET='0131'X PGSFLAGS='00'X PGSLTH=32 PGSLTH='0020'X


C5F1F100 C5F0F100 F0F0F0F0 F9F00010 D6D7C5D9 C1E3C9D6 D5E2

RECORD: XOFFSET='0105'X PGSFLAGS='00'X PGSLTH=44 PGSLTH='002C'X PGSOBD='0000'X PGSBID='07'X


C4F2F100 C4F0F100 F0F0F0F0 F7F00010 C1C4D4C9 D5C9E2E3 D9C1E3C9 D6D540E2
D21.D01.000070..ADMINISTRATION S
E8E2E3C5 D4E2
YSTEMS

RECORD: XOFFSET='00DA'X PGSFLAGS='00'X PGSLTH=43 PGSLTH='002B'X PGSOBD='0000'X PGSBID='06'X


C4F1F100 C4F0F100 F0F0F0F0 F6F00010 D4C1D5E4 C6C1C3E3 E4D9C9D5 C740E2E8
D11.D01.000060..MANUFACTURING SY
E2E3C5D4 E2
STEMS

RECORD: XOFFSET='00B4'X PGSFLAGS='00'X PGSLTH=38 PGSLTH='0026'X PGSOBD='0000'X PGSBID='05'X


C5F0F100 C1F0F000 F0F0F0F0 F5F00010 E2E4D7D7 D6D9E340 E2C5D9E5 C9C3C5E2
E01.A00.000050..SUPPORT SERVICES

RECORD: XOFFSET='008C'X PGSFLAGS='00'X PGSLTH=40 PGSLTH='0028'X PGSOBD='0000'X PGSBID='04'X


C4F0F100 C1F0F0FF 00000000 00000010 C4C5E5C5 D3D6D7D4 C5D5E340 C3C5D5E3
D01.A00.........DEVELOPMENT CENT
C5D9
ER

RECORD: XOFFSET='0064'X PGSFLAGS='00'X PGSLTH=40 PGSLTH='0028'X PGSOBD='0000'X PGSBID='03'X


C3F0F100 C1F0F000 F0F0F0F0 F3F00010 C9D5C6D6 D9D4C1E3 C9D6D540 C3C5D5E3
C01.A00.000030..INFORMATION CENT
1C5D9
ER

RECORD: XOFFSET='0046'X PGSFLAGS='00'X PGSLTH=30 PGSLTH='001E'X


C2F0F100 C1F0F000 F0F0F0F0 F2F00010 D7D3C1D5 D5C9D5C7

RECORD: XOFFSET='0014'X PGSFLAGS='00'X PGSLTH=50 PGSLTH='0032'X PGSOBD='0000'X PGSBID='01'X


C1F0F0FF 00000000 F0F0F0F0 F1F00010 E2D7C9C6 C6E840C3 D6D4D7E4 E3C5D940
A00.....000010..SPIFFY COMPUTER
E2C5D9E5 C9C3C540 C4C9E54B
SERVICE DIV.

PAGE: # 00000002
---------------------------------------------------------------------------------------------------------------DATA PAGE: PGCOMB='00'X PGLOGRBA='00000609E517'X PGNUM='00000002'X PGFLAGS='00'X PGFREE=3693
PGFREE='0E6D'X PGFREEP=527 PGFREEP='020F'X PGHOLE1='0000'X PGMAXID='0D'X PGNANCH=8
PGTAIL: PGIDFREE='00'X PGEND='E'
ID-MAP FOLLOWS:
01 0014 0046 0064 008C 00B4 00DA 0105 0131
09 0151 8177 819D 81C3 81E9

Step 43: DS1PRNT output, part 2 of 2

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-93

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

A-94 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 7: Running RUNSTATS and REORG


Questions relating to real-time statistics
1. What is L7QUERY1 doing?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

***************************** Top of Data ********************


SELECT DBNAME,NAME,UPDATESTATSTIME,TOTALROWS,STATSLASTTIME,
STATSINSERTS,STATSDELETES,STATSUPDATES,STATSMASSDELETE
FROM SYSIBM.SYSTABLESPACESTATS
WHERE DBNAME='WWV83??D' AND NAME='TSPROJ'
WITH UR ;
**************************** Bottom of Data ******************

The query reads the row for table space TSPROJ in your database from the
real-time statistics catalog table SYSIBM.SYSTABLESPACESTATS.

Table 9: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space TSPROJ


TOTALROWS

403

STATSINSERTS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

113

2. Is TOTALROWS what you expect?

Yes. There are 290 rows loaded into the PROJECT table, 39 rows loaded into the
ON_PROJECT table and 74 rows loaded into the ACTIVITY table, for a total of 403
rows.

3. Explain the STATSINSERTS value.

pr

Ex

cl

The LOAD REPLACE of table PROJECT contained the keyword STATISTICS. That
is why the counters STATS... have been reset to 0, as they show only what
happened since the last RUNSTATS (or inline statistics). The LOAD for tables
ON_PROJECT and ACTIVITY was a LOAD RESUME YES. The STATS... counters
are not reset and the rows added to the table space are counted as inserts. 39 for
table ON_PROJECT and 74 for table ACTIVITY, for a total of 113 inserts since the
last RUNSTATS.

4. Would you recommend to run RUNSTATS on table space TSPROJ?


Yes. The number of rows changed (113) is more than 20% of the total number of
rows in the table space (403).

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-95

Student Exercises

5. What type of disorganization might SQL statement L7UPDATE introduce into the table
space?
UPDATE PROJECT
SET NAME = 'FILLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL'
WHERE PROJNO BETWEEN 'PL2101' AND 'PL2220'

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 120
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Table space TSPROJ was defined with zero free space (see exercise 1) and the
update has increased the length of 120 rows. This might require some of the
updated rows to overflow to another page.

6. Are there changes in real-time statistics immediately after the updates?

No. DB2 externalizes the real-time statistics only after n minutes, n being a
system parameter. As the query of the real-time statistics values immediately
followed the update statement, it is extremely unlikely to see the correct values
already.

Table 10: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space TSPROJ


TOTALROWS

403

STATSINSERTS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

113

7. After a while, execute member L7QUERY1. Is STATSUPDATES now what you expect?
Yes, after a few minutes, STATSUPDATES should be 120.

cl

Table 11: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space TSPROJ


TOTALROWS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

113

120

pr

Ex

403

STATSINSERTS

A-96 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU610I

DSNU610I
DSNU614I

DSNU610I
DSNU614I

DSNU610I
DSNU614I

DSNU613I

1DSNU000I
DSNU1044I
0DSNU050I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.71 DSNUSUTP


CARD
CARDF
NEARINDREF
FARINDREF
PERCACTIVE
PERCDROP
PAGESAVE
SPACE
SPACEF
PQTY
SQTY
DSNUM
EXTENTS
-DSNB 241 07:35:16.72 DSNUSUTP
-DSNB 241 07:35:16.72 DSNUSUTB
CARD
CARDF
NPAGES
NPAGESF
PCTPAGES
PCTROWCOMP
AVGROWLEN
SPACEF
-DSNB 241 07:35:16.72 DSNUSUTB
-DSNB 241 07:35:16.72 DSNUSUTB
CARD
CARDF
NPAGES
NPAGESF
PCTPAGES
PCTROWCOMP
AVGROWLEN
SPACEF
-DSNB 241 07:35:16.72 DSNUSUTB
-DSNB 241 07:35:16.72 DSNUSUTB
CARD
CARDF
NPAGES
NPAGESF
PCTPAGES
PCTROWCOMP
AVGROWLEN
SPACEF
-DSNB 241 07:35:16.72 DSNUSUTB

- SYSTABLEPART CATALOG STATISTICS FOR WWV8301D.TSPROJ PARTITION 0


= 403
= 4.03E+02
= 0
= 48
= 1
= 0
= 0
= 2160
= 2.16E+03
= -1
= -1
= 1
= 2
- SYSTABLEPART CATALOG UPDATE FOR WWV8301D.TSPROJ SUCCESSFUL
- SYSTABLES CATALOG STATISTICS FOR TSOUB01.PROJECT
= 290
= 2.9E+02
= 5
= 5.0E+00
= 62
= 0
= 70
= 2.0E+01
- SYSTABLES CATALOG UPDATE FOR TSOUB01.PROJECT SUCCESSFUL
- SYSTABLES CATALOG STATISTICS FOR TSOUB01.ON_PROJECT
= 39
= 3.9E+01
= 1
= 1.0E+00
= 25
= 0
= 20
= 4.0E+00
- SYSTABLES CATALOG UPDATE FOR TSOUB01.ON_PROJECT SUCCESSFUL
- SYSTABLES CATALOG STATISTICS FOR TSOUB01.ACTIVITY
= 74
= 7.4E+01
= 1
= 1.0E+00
= 25
= 0
= 38
= 4.0E+00
- SYSTABLES CATALOG UPDATE FOR TSOUB01.ACTIVITY SUCCESSFUL

241 07:35:16.64 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


241 07:35:16.66 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
241 07:35:16.67 DSNUGUTC - RUNSTATS TABLESPACE WWV8301D.TSPROJ INDEX(ALL) SHRLEVEL CHANGE REPORT YES

Steps 8 to 10: RUNSTATS utility output, part 1 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-97

A-98 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU610I

DSNU610I
DSNU618I

DSNU610I
DSNU618I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.72 DSNUSUTS - SYSTABLESPACE CATALOG STATISTICS FOR WWV8301D.TSPROJ


NACTIVE
= 540
NACTIVEF
= 5.4E+02
-DSNB 241 07:35:16.72 DSNUSUTS - SYSTABLESPACE CATALOG UPDATE FOR WWV8301D.TSPROJ SUCCESSFUL
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXPROJ3 PARTITION 0
CARD
= 290
CARDF
= 2.9E+02
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 1
FAROFFPOSF
= 1.0E+00
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXPROJ1 PARTITION 0
CARD
= 290
CARDF
= 2.9E+02
NEAROFFPOS
= 6
NEAROFFPOSF
= 6.0E+00
FAROFFPOS
= 2
FAROFFPOSF
= 2.0E+00
LEAFDIST
= 50
LEAFNEAR
= 1
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXPROJ1 SUCCESSFUL
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXPROJ2 PARTITION 0
CARD
= 290
CARDF
= 2.9E+02
NEAROFFPOS
= 4
NEAROFFPOSF
= 4.0E+00
FAROFFPOS
= 1
FAROFFPOSF
= 1.0E+00
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL

pr

DSNU610I
DSNU618I

DSNU612I

Steps 8 to 10: RUNSTATS utility output, part 2 of 8

cl

Ex
Student Exercises

Copyright IBM Corp. 1993, 2011

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU610I

DSNU610I
DSNU618I

DSNU610I
DSNU618I

DSNU618I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXONPR2 PARTITION 0
CARD
= 39
CARDF
= 3.9E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXONPR1 PARTITION 0
CARD
= 39
CARDF
= 3.9E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 07:35:16.74 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL
-DSNB 241 07:35:16.75 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXACTY1 PARTITION 0
CARD
= 74
CARDF
= 7.4E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 07:35:16.75 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL

Steps 8 to 10: RUNSTATS utility output, part 3 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-99

A-100 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU610I

DSNU610I
DSNU617I

DSNU610I
DSNU615I

DSNU610I
DSNU617I

DSNU610I
DSNU615I

DSNU618I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.75 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXACTY2 PARTITION 0
CARD
= 74
CARDF
= 7.4E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 07:35:16.76 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
-DSNB 241 07:35:16.76 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR EMPNO
COLCARD
= 17
COLCARDF
= 1.7E+01
HIGH2KEY
= X'F0F0F0F3F3F0'
LOW2KEY
= X'F0F0F0F0F2F0'
-DSNB 241 07:35:16.76 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL
-DSNB 241 07:35:16.76 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXPROJ3
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 17
FIRSTKEYCARDF
= 1.7E+01
FULLKEYCARD
= 17
FULLKEYCARDF
= 1.7E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 5.0E+00
-DSNB 241 07:35:16.76 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL
-DSNB 241 07:35:16.76 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR PROJNO
COLCARD
= 290
COLCARDF
= 2.9E+02
HIGH2KEY
= X'D7D3F2F2F3F9'
LOW2KEY
= X'C1C4F3F1F1F0'
-DSNB 241 07:35:16.76 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXPROJ1 SUCCESSFUL
-DSNB 241 07:35:16.76 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXPROJ1
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 290
FIRSTKEYCARDF
= 2.9E+02
FULLKEYCARD
= 290
FULLKEYCARDF
= 2.9E+02
NLEAF
= 2
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 4.0E+00
-DSNB 241 07:35:16.76 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXPROJ1 SUCCESSFUL

pr

cl

Ex

Steps 8 to 10: RUNSTATS utility output, part 4 of 8

Student Exercises

Copyright IBM Corp. 1993, 2011

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

DSNU610I

DSNU610I
DSNU617I

DSNU610I
DSNU615I

DSNU610I
DSNU617I

DSNU610I
DSNU615I

DSNU610I
DSNU617I

DSNU615I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR DEPTNO


COLCARD
= 8
COLCARDF
= 8.0E+00
HIGH2KEY
= X'C5F1F1'
LOW2KEY
= X'C3F0F1'
-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXPROJ2
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 8
FIRSTKEYCARDF
= 8.0E+00
FULLKEYCARD
= 8
FULLKEYCARDF
= 8.0E+00
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 5.0E+00
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL
-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR EMPNO
COLCARD
= 30
COLCARDF
= 3.0E+01
HIGH2KEY
= X'F0F0F0F3F3F0'
LOW2KEY
= X'F0F0F0F0F2F0'
-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXONPR2
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 30
FIRSTKEYCARDF
= 3.0E+01
FULLKEYCARD
= 30
FULLKEYCARDF
= 3.0E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL
-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR PROJNO
COLCARD
= 19
COLCARDF
= 1.9E+01
HIGH2KEY
= X'D6D7F2F0F1F3'
LOW2KEY
= X'C1C4F3F1F1F0'
-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXONPR1
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 19
FIRSTKEYCARDF
= 1.9E+01
FULLKEYCARD
= 39
FULLKEYCARDF
= 3.9E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL

Steps 8 to 10: RUNSTATS utility output, part 5 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

A-101

A-102 DB2 10 for z/OS DB Admin Workshop Part 1

DSNU610I

DSNU610I
DSNU616I

DSNU610I
DSNU617I

DSNU610I
DSNU615I

DSNU610I
DSNU617I

DSNU615I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR PROJNO


COLCARD
= 19
COLCARDF
= 1.9E+01
HIGH2KEY
= X'D6D7F2F0F1F3'
LOW2KEY
= X'C1C4F3F1F1F0'
-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXACTY1
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 19
FIRSTKEYCARDF
= 1.9E+01
FULLKEYCARD
= 74
FULLKEYCARDF
= 7.4E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
-DSNB 241 07:35:16.77 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL
-DSNB 241 07:35:16.77 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR EMPNO
COLCARD
= 30
COLCARDF
= 3.0E+01
HIGH2KEY
= X'F0F0F0F3F3F0'
LOW2KEY
= X'F0F0F0F0F2F0'
-DSNB 241 07:35:16.78 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
-DSNB 241 07:35:16.78 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXACTY2
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 30
FIRSTKEYCARDF
= 3.0E+01
FULLKEYCARD
= 30
FULLKEYCARDF
= 3.0E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
-DSNB 241 07:35:16.78 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
-DSNB 241 07:35:16.78 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
EMPNO
FREQUENCY
COLVALUE
---------------4.8620689655172E-01 X'F0F0F0F0F2F0'
1.7586206896551E-01 X'F0F0F0F0F6F0'
1.7586206896551E-01 X'F0F0F0F1F0F0'
1.0689655172413E-01 X'F0F0F0F2F7F0'
6.8965517241379E-03 X'F0F0F0F0F1F0'
6.8965517241379E-03 X'F0F0F0F0F3F0'
6.8965517241379E-03 X'F0F0F0F0F5F0'
3.4482758620689E-03 X'F0F0F0F0F7F0'
3.4482758620689E-03 X'F0F0F0F0F9F0'
3.4482758620689E-03 X'F0F0F0F1F5F0'
-DSNB 241 07:35:16.78 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL

pr

cl

Ex

Steps 8 to 10: RUNSTATS utility output, part 6 of 8

Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU616I

DSNU610I
DSNU616I

DSNU610I
DSNU616I

DSNU610I
DSNU616I

DSNU616I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.78 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR


DEPTNO
FREQUENCY
COLVALUE
---------------4.8620689655172E-01 X'C2F0F1'
1.8620689655172E-01 X'C4F1F1'
1.8620689655172E-01 X'C5F2F1'
1.1724137931034E-01 X'C4F2F1'
6.8965517241379E-03 X'C3F0F1'
6.8965517241379E-03 X'C4F0F1'
6.8965517241379E-03 X'C5F0F1'
3.4482758620689E-03 X'C5F1F1'
-DSNB 241 07:35:16.78 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL
-DSNB 241 07:35:16.78 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
EMPNO
FREQUENCY
COLVALUE
---------------7.6923076923076E-02 X'F0F0F0F0F1F0'
7.6923076923076E-02 X'F0F0F0F0F3F0'
5.1282051282051E-02 X'F0F0F0F0F5F0'
5.1282051282051E-02 X'F0F0F0F1F3F0'
5.1282051282051E-02 X'F0F0F0F1F4F0'
5.1282051282051E-02 X'F0F0F0F1F7F0'
5.1282051282051E-02 X'F0F0F0F3F0F0'
2.5641025641025E-02 X'F0F0F0F0F2F0'
2.5641025641025E-02 X'F0F0F0F0F7F0'
2.5641025641025E-02 X'F0F0F0F0F9F0'
-DSNB 241 07:35:16.78 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL
-DSNB 241 07:35:16.78 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
PROJNO
FREQUENCY
COLVALUE
---------------1.2820512820512E-01 X'D6D7F1F0F1F0'
1.025641025641E-01 X'D4C1F2F1F1F3'
7.6923076923076E-02 X'C9C6F1F0F0F0'
7.6923076923076E-02 X'D4C1F2F1F1F2'
7.6923076923076E-02 X'D7D3F2F1F0F0'
5.1282051282051E-02 X'C1C4F3F1F0F0'
5.1282051282051E-02 X'C1C4F3F1F1F1'
5.1282051282051E-02 X'C1C4F3F1F1F3'
5.1282051282051E-02 X'C9C6F2F0F0F0'
5.1282051282051E-02 X'D4C1F2F1F0F0'
-DSNB 241 07:35:16.79 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL
-DSNB 241 07:35:16.79 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
PROJNO,EMPNO
CARDINALITY = 3.6E+01
-DSNB 241 07:35:16.79 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
PROJNO,EMPNO,SEQNO
CARDINALITY = 7.4E+01

Steps 8 to 10: RUNSTATS utility output, part 7 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-103

A-104 DB2 10 for z/OS DB Admin Workshop Part 1

DSNU610I
DSNU620I
DSNU010I

DSNU610I
DSNU616I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 07:35:16.79 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR


PROJNO
FREQUENCY
COLVALUE
---------------1.8918918918918E-01 X'C1C4F3F1F1F3'
1.3513513513513E-01 X'C1C4F3F1F1F2'
9.4594594594594E-02 X'C1C4F3F1F1F1'
8.1081081081081E-02 X'D4C1F2F1F1F2'
6.7567567567567E-02 X'C9C6F2F0F0F0'
6.7567567567567E-02 X'D4C1F2F1F1F3'
6.7567567567567E-02 X'D6D7F1F0F1F0'
5.4054054054054E-02 X'C9C6F1F0F0F0'
4.054054054054E-02 X'D4C1F2F1F1F1'
2.7027027027027E-02 X'D4C1F2F1F0F0'
-DSNB 241 07:35:16.79 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL
-DSNB 241 07:35:16.79 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
EMPNO
FREQUENCY
COLVALUE
---------------1.3513513513513E-01 X'F0F0F0F2F5F0'
9.4594594594594E-02 X'F0F0F0F2F6F0'
9.4594594594594E-02 X'F0F0F0F2F7F0'
6.7567567567567E-02 X'F0F0F0F1F4F0'
6.7567567567567E-02 X'F0F0F0F2F3F0'
4.054054054054E-02 X'F0F0F0F0F1F0'
4.054054054054E-02 X'F0F0F0F1F7F0'
2.7027027027027E-02 X'F0F0F0F0F3F0'
2.7027027027027E-02 X'F0F0F0F0F5F0'
2.7027027027027E-02 X'F0F0F0F1F3F0'
-DSNB 241 07:35:16.79 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
-DSNB 241 07:35:16.80 DSNUSEOF - RUNSTATS CATALOG TIMESTAMP = 2011-08-29-07.35.16.678754
241 07:35:16.80 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

pr

DSNU616I

Steps 8 to 10: RUNSTATS utility output, part 8 of 8

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Questions relating to RUNSTATS report


Table 12: SYSIBM.SYSTABLEPART Catalog Statistics
NEARINDREF

FARINDREF

403

48

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CARDF

Table 13: SYSIBM.SYSINDEXPART Catalog Statistics


Index Name

CARDF

NEAROFFPOSF

FAROFFPOSF

LEAFFAR

IXPROJ3

290

IXPROJ1

290

IXPROJ2

290

IXONPR2

39

IXONPR1

39

IXACTY1

74

IXACTY2

74

Step 11: Same values as with real-time statistics? why STATSINSERTS,


STATSUPDATES now 0?
Executing L7QUERY1 once again (to get current real-time statistics values) yields:

Table 14: SYSIBM.SYSTABLESPACESTATS Real-Time Statistics for table space TSPROJ


TOTALROWS

STATSDELETES

STATSUPDATES

STATSMASSDELETE

cl

403

STATSINSERTS

Ex

Same values?

Catalog: CARDF=403 and TOTALROWS = 403.

pr

STATSINSERTS and STATSUPDATES = 0, as previous RUNSTATS with UPDATE ALL


has reset RTS statistics counters. (Remark: RUNSTATS with UPDATE SPACE does NOT
reset the statistics counters.)

Step 12: Have any variable length rows overflowed to another page?
Yes, RUNSTATS output states: FARINDREF is now 48

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-105

Student Exercises

Step 13: Why is the data for the PROJECT table still reported as being
well-clustered even though a number of rows in the PROJECT table
have overflowed?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

The data for the PROJECT table is reported as well clustered (CLUSTERRATIO for
index IXPROJ3 is 100%), because index IXPROJ3 still points to where the rows were
originally located.

pr

Ex

cl

Conditional REORGs follow:

A-106 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1DSNU000I
241 12:32:40.31 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 12:32:40.34 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 12:32:40.34 DSNUGUTC - REORG TABLESPACE WWV8301D.TSPROJ REPORTONLY OFFPOSLIMIT 15 INDREFLIMIT 15
DSNU286I -DSNB 241 12:32:40.41 DSNURLIM - REORG TABLESPACE WWV8301D.TSPROJ OFFPOSLIMIT SYSINDEXPART ROWS
CREATOR.IXNAME: TSOUB01.IXPROJ3
CREATOR.TBNAME: TSOUB01.PROJECT
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0
2.9E+02
1.0E+00
0.0E+00
2011-08-29-07.35.16
CREATOR.IXNAME: TSOUB01.IXONPR2
CREATOR.TBNAME: TSOUB01.ON_PROJECT
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0
3.9E+01
0.0E+00
0.0E+00
2011-08-29-07.35.16
CREATOR.IXNAME: TSOUB01.IXACTY1
CREATOR.TBNAME: TSOUB01.ACTIVITY
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0 -1.0E+00
-1.0E+00
-1.0E+00
0001-01-01-00.00.00
DSNU287I -DSNB 241 12:32:40.41 DSNURLIM - REORG TABLESPACE WWV8301D.TSPROJ INDREFLIMIT SYSTABLEPART ROWS
DBNAME .TSNAME
PART
CARD FARINDREF NEARINDREF
STATSTIME
WWV8301D.TSPROJ
0
403
48
0 2011-08-29-07.35.16
DSNU289I -DSNB 241 12:32:40.41 DSNURLIM - NO REORG LIMITS HAVE BEEN MET
DSNU010I
241 12:32:40.41 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=1

Steps 14 to 16: REORG TABLESPACE utility output

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-107

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

A-108 DB2 10 for z/OS DB Admin Workshop Part 1

Rows which meet the limit criteria are prefaced with *.

1DSNU000I
241 12:37:38.06 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 12:37:38.09 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 12:37:38.09 DSNUGUTC - REORG TABLESPACE WWV8301D.TSPROJ REPORTONLY OFFPOSLIMIT 10 INDREFLIMIT 10
DSNU286I -DSNB 241 12:37:38.09 DSNURLIM - REORG TABLESPACE WWV8301D.TSPROJ OFFPOSLIMIT SYSINDEXPART ROWS
CREATOR.IXNAME: TSOUB01.IXPROJ3
CREATOR.TBNAME: TSOUB01.PROJECT
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0
2.9E+02
1.0E+00
0.0E+00
2011-08-29-07.35.16
CREATOR.IXNAME: TSOUB01.IXONPR2
CREATOR.TBNAME: TSOUB01.ON_PROJECT
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0
3.9E+01
0.0E+00
0.0E+00
2011-08-29-07.35.16
CREATOR.IXNAME: TSOUB01.IXACTY1
CREATOR.TBNAME: TSOUB01.ACTIVITY
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0 -1.0E+00
-1.0E+00
-1.0E+00
0001-01-01-00.00.00
DSNU287I -DSNB 241 12:37:38.09 DSNURLIM - REORG TABLESPACE WWV8301D.TSPROJ INDREFLIMIT SYSTABLEPART ROWS
DBNAME .TSNAME
PART
CARD FARINDREF NEARINDREF
STATSTIME
* WWV8301D.TSPROJ
0
403
48
0 2011-08-29-07.35.16
DSNU289I -DSNB 241 12:37:38.09 DSNURLIM - REORG LIMITS HAVE BEEN MET
DSNU010I
241 12:37:38.10 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=2

pr

Steps 17 to 18: REORG TABLESPACE utility output

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Step 19: REORG TABLESPACE statement, third version

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

REORG TABLESPACE WWV8301D.TSPROJ


OFFPOSLIMIT 10 INDREFLIMIT 10
STATISTICS
INDEX( ALL )
REPORT YES
UPDATE ALL

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-109

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1DSNU000I
241 12:44:07.43 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 12:44:07.46 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 12:44:07.46 DSNUGUTC - REORG TABLESPACE WWV8301D.TSPROJ OFFPOSLIMIT 10 INDREFLIMIT 10 STATISTICS
INDEX(ALL) REPORT(YES)
DSNU286I -DSNB 241 12:44:07.46 DSNURLIM - REORG TABLESPACE WWV8301D.TSPROJ OFFPOSLIMIT SYSINDEXPART ROWS
CREATOR.IXNAME: TSOUB01.IXPROJ3
CREATOR.TBNAME: TSOUB01.PROJECT
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0
2.9E+02
1.0E+00
0.0E+00
2011-08-29-07.35.16
CREATOR.IXNAME: TSOUB01.IXONPR2
CREATOR.TBNAME: TSOUB01.ON_PROJECT
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0
3.9E+01
0.0E+00
0.0E+00
2011-08-29-07.35.16
CREATOR.IXNAME: TSOUB01.IXACTY1
CREATOR.TBNAME: TSOUB01.ACTIVITY
PART CARDF
FAROFFPOSF
NEAROFFPOSF
STATSTIME
0
7.4E+01
0.0E+00
0.0E+00
2011-08-29-07.35.16
DSNU287I -DSNB 241 12:44:07.46 DSNURLIM - REORG TABLESPACE WWV8301D.TSPROJ INDREFLIMIT SYSTABLEPART ROWS
DBNAME .TSNAME
PART
CARD FARINDREF NEARINDREF
STATSTIME
* WWV8301D.TSPROJ
0
403
48
0 2011-08-29-07.35.16
DSNU289I -DSNB 241 12:44:07.46 DSNURLIM - REORG LIMITS HAVE BEEN MET
DSNU290I -DSNB 241 12:44:07.46 DSNURLIM - REORG WILL BE PERFORMED
DSNU252I
241 12:44:07.54 DSNURULD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS UNLOADED=403 FOR TABLESPACE
WWV8301D.TSPROJ
DSNU250I
241 12:44:07.54 DSNURULD - UNLOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU304I -DSNB 241 12:44:08.48 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=290 FOR TABLE TSOUB01.PROJECT
DSNU304I -DSNB 241 12:44:08.48 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=39 FOR TABLE TSOUB01.ON_PROJECT
DSNU304I -DSNB 241 12:44:08.48 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=74 FOR TABLE TSOUB01.ACTIVITY
DSNU302I
241 12:44:08.49 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=403
DSNU300I
241 12:44:08.49 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU042I
241 12:44:08.49 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=1096
ELAPSED TIME=00:00:00
DSNU349I -DSNB 241 12:44:08.53 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=290 FOR INDEX TSOUB01.IXPROJ1
DSNU349I -DSNB 241 12:44:08.56 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=290 FOR INDEX TSOUB01.IXPROJ2
DSNU349I -DSNB 241 12:44:08.58 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=290 FOR INDEX TSOUB01.IXPROJ3
DSNU349I -DSNB 241 12:44:08.62 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=39 FOR INDEX TSOUB01.IXONPR1
DSNU349I -DSNB 241 12:44:08.64 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=39 FOR INDEX TSOUB01.IXONPR2
DSNU349I -DSNB 241 12:44:08.67 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=74 FOR INDEX TSOUB01.IXACTY1
DSNU349I -DSNB 241 12:44:08.70 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=74 FOR INDEX TSOUB01.IXACTY2
DSNU258I
241 12:44:08.73 DSNURBXD - BUILD PHASE STATISTICS - NUMBER OF INDEXES=7
DSNU259I
241 12:44:08.73 DSNURBXD - BUILD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU613I -DSNB 241 12:44:08.74 DSNUSUTP - SYSTABLEPART CATALOG STATISTICS FOR WWV8301D.TSPROJ PARTITION 0
CARD
= 403
CARDF
= 4.03E+02
NEARINDREF
= 0
FARINDREF
= 0
PERCACTIVE
= 37
PERCDROP
= 0
PAGESAVE
= 0
SPACE
= 720
SPACEF
= 7.2E+02
PQTY
= -1
SQTY
= -1
DSNUM
= 1
EXTENTS
= 1
DSNU610I -DSNB 241 12:44:08.74 DSNUSUTP - SYSTABLEPART CATALOG UPDATE FOR WWV8301D.TSPROJ SUCCESSFUL

pr

Step 20: REORG TABLESPACE utility output, part 1 of 8

cl

Ex
Student Exercises

A-110 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

Copyright IBM Corp. 1993, 2011

DSNU610I

DSNU610I
DSNU618I

DSNU610I
DSNU612I

DSNU610I
DSNU614I

DSNU610I
DSNU614I

DSNU614I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 12:44:08.74 DSNUSUTB - SYSTABLES CATALOG STATISTICS FOR TSOUB01.PROJECT


CARD
= 290
CARDF
= 2.9E+02
NPAGES
= 5
NPAGESF
= 5.0E+00
PCTPAGES
= 62
PCTROWCOMP
= 0
AVGROWLEN
= 69
SPACEF
= 2.0E+01
-DSNB 241 12:44:08.75 DSNUSUTB - SYSTABLES CATALOG UPDATE FOR TSOUB01.PROJECT SUCCESSFUL
-DSNB 241 12:44:08.75 DSNUSUTB - SYSTABLES CATALOG STATISTICS FOR TSOUB01.ON_PROJECT
CARD
= 39
CARDF
= 3.9E+01
NPAGES
= 1
NPAGESF
= 1.0E+00
PCTPAGES
= 25
PCTROWCOMP
= 0
AVGROWLEN
= 20
SPACEF
= 4.0E+00
-DSNB 241 12:44:08.75 DSNUSUTB - SYSTABLES CATALOG UPDATE FOR TSOUB01.ON_PROJECT SUCCESSFUL
-DSNB 241 12:44:08.75 DSNUSUTB - SYSTABLES CATALOG STATISTICS FOR TSOUB01.ACTIVITY
CARD
= 74
CARDF
= 7.4E+01
NPAGES
= 1
NPAGESF
= 1.0E+00
PCTPAGES
= 25
PCTROWCOMP
= 0
AVGROWLEN
= 38
SPACEF
= 4.0E+00
-DSNB 241 12:44:08.75 DSNUSUTB - SYSTABLES CATALOG UPDATE FOR TSOUB01.ACTIVITY SUCCESSFUL
-DSNB 241 12:44:08.75 DSNUSUTS - SYSTABLESPACE CATALOG STATISTICS FOR WWV8301D.TSPROJ
NACTIVE
= 15
NACTIVEF
= 1.5E+01
-DSNB 241 12:44:08.75 DSNUSUTS - SYSTABLESPACE CATALOG UPDATE FOR WWV8301D.TSPROJ SUCCESSFUL
-DSNB 241 12:44:08.76 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXPROJ3 PARTITION 0
CARD
= 290
CARDF
= 2.9E+02
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 1
FAROFFPOSF
= 1.0E+00
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 12:44:08.76 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL

Step 20: REORG TABLESPACE utility output, part 2 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-111

A-112 DB2 10 for z/OS DB Admin Workshop Part 1

DSNU610I

DSNU610I
DSNU618I

DSNU610I
DSNU618I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXPROJ1 PARTITION 0
CARD
= 290
CARDF
= 2.9E+02
NEAROFFPOS
= 74
NEAROFFPOSF
= 7.4E+01
FAROFFPOS
= 8
FAROFFPOSF
= 8.0E+00
LEAFDIST
= 50
LEAFNEAR
= 1
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXPROJ1 SUCCESSFUL
-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXPROJ2 PARTITION 0
CARD
= 290
CARDF
= 2.9E+02
NEAROFFPOS
= 2
NEAROFFPOSF
= 2.0E+00
FAROFFPOS
= 5
FAROFFPOSF
= 5.0E+00
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL
-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXONPR2 PARTITION 0
CARD
= 39
CARDF
= 3.9E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL

pr

DSNU618I

step 20: REORG TABLESPACE utility output, part 3 of 8

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU610I
DSNU615I

DSNU610I
DSNU618I

DSNU610I
DSNU618I

DSNU618I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXONPR1 PARTITION 0
CARD
= 39
CARDF
= 3.9E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 12:44:08.77 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL
-DSNB 241 12:44:08.78 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXACTY1 PARTITION 0
CARD
= 74
CARDF
= 7.4E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 12:44:08.79 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL
-DSNB 241 12:44:08.79 DSNUSUIP - SYSINDEXPART CATALOG STATISTICS FOR TSOUB01.IXACTY2 PARTITION 0
CARD
= 74
CARDF
= 7.4E+01
NEAROFFPOS
= 0
NEAROFFPOSF
= 0.0E0
FAROFFPOS
= 0
FAROFFPOSF
= 0.0E0
LEAFDIST
= 0
LEAFNEAR
= 0
LEAFFAR
= 0
SPACE
= 720
SPACEF
= 7.2E+02
DSNUM
= 1
EXTENTS
= 1
P_DEL_ENT
= 0
PQTY
= -1
SQTY
= -1
-DSNB 241 12:44:08.79 DSNUSUIP - SYSINDEXPART CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
-DSNB 241 12:44:08.79 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR EMPNO
COLCARD
= 17
COLCARDF
= 1.7E+01
HIGH2KEY
= X'F0F0F0F3F3F0'
LOW2KEY
= X'F0F0F0F0F2F0'

Step 20: REORG TABLESPACE utility output, part 4 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-113

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DSNU610I -DSNB 241 12:44:08.79 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL
DSNU617I -DSNB 241 12:44:08.79 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXPROJ3
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 17
FIRSTKEYCARDF
= 1.7E+01
FULLKEYCARD
= 17
FULLKEYCARDF
= 1.7E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 5.0E+00
DSNU610I -DSNB 241 12:44:08.79 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL
DSNU615I -DSNB 241 12:44:08.79 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR PROJNO
COLCARD
= 290
COLCARDF
= 2.9E+02
HIGH2KEY
= X'D7D3F2F2F3F9'
LOW2KEY
= X'C1C4F3F1F1F0'
DSNU610I -DSNB 241 12:44:08.79 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXPROJ1 SUCCESSFUL
DSNU617I -DSNB 241 12:44:08.79 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXPROJ1
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 290
FIRSTKEYCARDF
= 2.9E+02
FULLKEYCARD
= 290
FULLKEYCARDF
= 2.9E+02
NLEAF
= 2
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 3.0E+00
DSNU610I -DSNB 241 12:44:08.79 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXPROJ1 SUCCESSFUL
DSNU615I -DSNB 241 12:44:08.79 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR DEPTNO
COLCARD
= 8
COLCARDF
= 8.0E+00
HIGH2KEY
= X'C5F1F1'
LOW2KEY
= X'C3F0F1'
DSNU610I -DSNB 241 12:44:08.79 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL
DSNU617I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXPROJ2
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 8
FIRSTKEYCARDF
= 8.0E+00
FULLKEYCARD
= 8
FULLKEYCARDF
= 8.0E+00
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 5.0E+00
DSNU610I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL
DSNU615I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR EMPNO
COLCARD
= 30
COLCARDF
= 3.0E+01
HIGH2KEY
= X'F0F0F0F3F3F0'
LOW2KEY
= X'F0F0F0F0F2F0'

pr

cl

Ex

Step 20: REORG TABLESPACE utility output, part 5 of 8

Student Exercises

A-114 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DSNU610I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL
DSNU617I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXONPR2
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 30
FIRSTKEYCARDF
= 3.0E+01
FULLKEYCARD
= 30
FULLKEYCARDF
= 3.0E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
DSNU610I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL
DSNU615I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR PROJNO
COLCARD
= 19
COLCARDF
= 1.9E+01
HIGH2KEY
= X'D6D7F2F0F1F3'
LOW2KEY
= X'C1C4F3F1F1F0'
DSNU610I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL
DSNU617I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXONPR1
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 19
FIRSTKEYCARDF
= 1.9E+01
FULLKEYCARD
= 39
FULLKEYCARDF
= 3.9E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
DSNU610I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL
DSNU615I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR PROJNO
COLCARD
= 19
COLCARDF
= 1.9E+01
HIGH2KEY
= X'D6D7F2F0F1F3'
LOW2KEY
= X'C1C4F3F1F1F0'
DSNU610I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL
DSNU617I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXACTY1
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 19
FIRSTKEYCARDF
= 1.9E+01
FULLKEYCARD
= 74
FULLKEYCARDF
= 7.4E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
DSNU610I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL
DSNU615I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG STATISTICS FOR EMPNO
COLCARD
= 30
COLCARDF
= 3.0E+01
HIGH2KEY
= X'F0F0F0F3F3F0'
LOW2KEY
= X'F0F0F0F0F2F0'

Step 20: REORG TABLESPACE utility output, part 6 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-115

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DSNU610I -DSNB 241 12:44:08.80 DSNUSUCO - SYSCOLUMNS CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
DSNU617I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG STATISTICS FOR TSOUB01.IXACTY2
CLUSTERED
= Y
CLUSTERRATIO
= 100
CLUSTERRATIOF
= 1.0E+00
FIRSTKEYCARD
= 30
FIRSTKEYCARDF
= 3.0E+01
FULLKEYCARD
= 30
FULLKEYCARDF
= 3.0E+01
NLEAF
= 1
NLEVELS
= 2
SPACEF
= 7.2E+02
DATAREPEATFACTORF = 1.0E+00
DSNU610I -DSNB 241 12:44:08.80 DSNUSUIX - SYSINDEXES CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
DSNU616I -DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
EMPNO
FREQUENCY
COLVALUE
---------------4.8620689655172E-01 X'F0F0F0F0F2F0'
1.7586206896551E-01 X'F0F0F0F0F6F0'
1.7586206896551E-01 X'F0F0F0F1F0F0'
1.0689655172413E-01 X'F0F0F0F2F7F0'
6.8965517241379E-03 X'F0F0F0F0F1F0'
6.8965517241379E-03 X'F0F0F0F0F3F0'
6.8965517241379E-03 X'F0F0F0F0F5F0'
3.4482758620689E-03 X'F0F0F0F0F7F0'
3.4482758620689E-03 X'F0F0F0F0F9F0'
3.4482758620689E-03 X'F0F0F0F1F5F0'
DSNU610I -DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXPROJ3 SUCCESSFUL
DSNU616I -DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
DEPTNO
FREQUENCY
COLVALUE
---------------4.8620689655172E-01 X'C2F0F1'
1.8620689655172E-01 X'C4F1F1'
1.8620689655172E-01 X'C5F2F1'
1.1724137931034E-01 X'C4F2F1'
6.8965517241379E-03 X'C3F0F1'
6.8965517241379E-03 X'C4F0F1'
6.8965517241379E-03 X'C5F0F1'
3.4482758620689E-03 X'C5F1F1'
DSNU610I -DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXPROJ2 SUCCESSFUL
DSNU616I -DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
EMPNO
FREQUENCY
COLVALUE
---------------7.6923076923076E-02 X'F0F0F0F0F1F0'
7.6923076923076E-02 X'F0F0F0F0F3F0'
5.1282051282051E-02 X'F0F0F0F0F5F0'
5.1282051282051E-02 X'F0F0F0F1F3F0'
5.1282051282051E-02 X'F0F0F0F1F4F0'
5.1282051282051E-02 X'F0F0F0F1F7F0'
5.1282051282051E-02 X'F0F0F0F3F0F0'
2.5641025641025E-02 X'F0F0F0F0F2F0'
2.5641025641025E-02 X'F0F0F0F0F7F0'
2.5641025641025E-02 X'F0F0F0F0F9F0'
DSNU610I -DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXONPR2 SUCCESSFUL

pr

cl

Ex

Step 20: REORG TABLESPACE utility output, part 7 of 8

Student Exercises

A-116 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU610I
DSNU620I
DSNU010I

DSNU610I
DSNU616I

DSNU616I

DSNU616I

DSNU610I
DSNU616I

DSNU616I

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR


PROJNO
FREQUENCY
COLVALUE
---------------1.2820512820512E-01 X'D6D7F1F0F1F0'
1.025641025641E-01 X'D4C1F2F1F1F3'
7.6923076923076E-02 X'C9C6F1F0F0F0'
7.6923076923076E-02 X'D4C1F2F1F1F2'
7.6923076923076E-02 X'D7D3F2F1F0F0'
5.1282051282051E-02 X'C1C4F3F1F0F0'
5.1282051282051E-02 X'C1C4F3F1F1F1'
5.1282051282051E-02 X'C1C4F3F1F1F3'
5.1282051282051E-02 X'C9C6F2F0F0F0'
5.1282051282051E-02 X'D4C1F2F1F0F0'
-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXONPR1 SUCCESSFUL
-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
PROJNO,EMPNO
CARDINALITY = 3.6E+01
-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
PROJNO,EMPNO,SEQNO
CARDINALITY = 7.4E+01
-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
PROJNO
FREQUENCY
COLVALUE
---------------1.8918918918918E-01 X'C1C4F3F1F1F3'
1.3513513513513E-01 X'C1C4F3F1F1F2'
9.4594594594594E-02 X'C1C4F3F1F1F1'
8.1081081081081E-02 X'D4C1F2F1F1F2'
6.7567567567567E-02 X'C9C6F2F0F0F0'
6.7567567567567E-02 X'D4C1F2F1F1F3'
6.7567567567567E-02 X'D6D7F1F0F1F0'
5.4054054054054E-02 X'C9C6F1F0F0F0'
4.054054054054E-02 X'D4C1F2F1F1F1'
2.7027027027027E-02 X'D4C1F2F1F0F0'
-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXACTY1 SUCCESSFUL
-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG STATISTICS FOR
EMPNO
FREQUENCY
COLVALUE
---------------1.3513513513513E-01 X'F0F0F0F2F5F0'
9.4594594594594E-02 X'F0F0F0F2F6F0'
9.4594594594594E-02 X'F0F0F0F2F7F0'
6.7567567567567E-02 X'F0F0F0F1F4F0'
6.7567567567567E-02 X'F0F0F0F2F3F0'
4.054054054054E-02 X'F0F0F0F0F1F0'
4.054054054054E-02 X'F0F0F0F1F7F0'
2.7027027027027E-02 X'F0F0F0F0F3F0'
2.7027027027027E-02 X'F0F0F0F0F5F0'
2.7027027027027E-02 X'F0F0F0F1F3F0'
-DSNB 241 12:44:08.80 DSNUSUCD - SYSCOLDIST CATALOG UPDATE FOR TSOUB01.IXACTY2 SUCCESSFUL
-DSNB 241 12:44:08.80 DSNUSEOF - RUNSTATS CATALOG TIMESTAMP = 2011-08-29-12.44.08.443115
241 12:44:08.93 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=2

Step 20: REORG TABLESPACE utility output, part 8 of 8

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-117

Student Exercises

Steps 20 to 21: Some results of the REORG report (xxxINDREFs now 0):
Table 15: SYSIBM.SYSTABLEPART Catalog Statistics
NEARINDREF

FARINDREF

403

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CARDF

Table 16: SYSIBM.SYSINDEXPART Catalog Statistics


CARDF

NEAROFFPOSF

FAROFFPOSF

LEAFFAR

IXPROJ3

290

IXPROJ1

290

74

IXPROJ2

290

IXONPR2

39

IXONPR1

39

IXACTY1

74

IXACTY2

74

pr

Ex

cl

Index Name

A-118 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 22 (optional): Calculating space


At the beginning, an overview graphic for TSPROJ; see below for explanations:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSPROJ
Table space Statistics
NACTIVE 15:

Number of pages formatted for rows


Not all pages may contain rows

ACTIVITY
CARDF 74
NPAGES 1
PCTPAGES 25%

PERCACTIVE 37:

Percentage of space
occupied by rows

CARD 403

ON_PROJECT
CARDF 39
NPAGES 1
PCTPAGES 25%

PROJECT
CARDF 290
NPAGES 5
PCTPAGES 62%

Space
Map

Header

Segment 4

Segment 3

Segment 2

Segment 1

IDCAMS
15 tracks
1 extent
ALLOCATION
SPACE TYPE - CYLINDER
SPACE PRI - 1
SPACE SEC - 1
HI-A-RBA 737280
HI-U-RBA 61440
CISIZE 4096
AVGLRECL 0
MAXLRECL 0

Copyright IBM Corporation 2007

cl

Step 22a: Number of segments

By reviewing the RUNSTATS output or by executing queries on the catalog, we know:

Ex

TSPROJ
------ page size: 4 KB
- SEGSIZE:
4 pages
- PCTFREE:
10 percent

pr

Tables
AVG_ROW_LENGTH AVG_RECORD_LENGTH COUNT(*)=CARD
----------------------- ----------------- ------------PROJECT
67
75
290
ON_PROJECT
18
26
39
ACTIVITY
36
44
74
where a) you must provide/estimate AVG_ROW_LENGTH and CARD, if data not yet stored in DB2;
b) AVG_RECORD_LENGTH includes 6 bytes for record header plus 2 bytes for id map entry.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-119

Student Exercises

Calculating the segments:


4096
4050
3600
= 48
--> 7

bytes
bytes
bytes
(max. 255 !)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

PROJECT:
- page size:
- net:
about
- minus PCTFREE:
about
- rows per page:
3600 : 75
- number of pages needed:
290 : 48

- number of segments needed: 7 : 4 ------> 2


ON_PROJECT:

ACTIVITY:

1
==
Sum
4 Segments
Remark: Precise record length for 4 K: 4096 - 20 header - 2 trailer = 4074.
But if only one record is stored, the max. length is 4056

Total number of pages needed:


----------------------------4 segments with 4 pages each:
plus HEADER and SPACEMAP PAGE:

16 pages
18 pages

Step 22b: Calculate the number of tracks


Number of tracks needed:
-----------------------number of 4K pages per 3390 track:
number of 3390 tracks:
18:12 -->

12 pages
2 tracks

Step 22c: Space allocated

Allocation typically defaults to 1 cylinder depending on zparm TSQTY (amount of space in KB, 0 means default of 1 cyl.)

cl

Use the IDCAMS command LISTCAT to retrieve the actual space allocated:

pr

Ex

***************************** Top of Data ***********************


//TSOUB01 JOB ,'TSOUB01',MSGLEVEL=(0,0),CLASS=A,NOTIFY=&SYSUID
//*
//* LISTCAT
//*
//IDCAMS
EXEC PGM=IDCAMS,REGION=2500K
//SYSPRINT DD SYSOUT=*
//SYSIN
DD *
LISTCAT LEVEL (DBDSNB.*.WWV8301D.TSPROJ) ALL
//
**************************** Bottom of Data *********************

A-120 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

PAGE

PAGE

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1IDCAMS SYSTEM SERVICES


TIME: 23:25:41
08/29/11
0
LISTCAT LEVEL (DBDSNB.*.WWV8301D.TSPROJ) ALL
1IDCAMS SYSTEM SERVICES
TIME: 23:25:41
08/29/11
LISTING FROM CATALOG -- ICFCAT.MVSW20.UCAT
0CLUSTER ------- DBDSNB.DSNDBC.WWV8301D.TSPROJ.I0001.A001
IN-CAT --- ICFCAT.MVSW20.UCAT
HISTORY
DATASET-OWNER----SYSPROG
CREATION--------2011.241
RELEASE----------------2
EXPIRATION------0000.000
SMSDATA
STORAGECLASS --------DB2
MANAGEMENTCLASS-STANDARD
DATACLASS --------(NULL)
LBACKUP ---0000.000.0000
CA-RECLAIM----------(NO)
EATTR-------------(NULL)
BWO STATUS------00000000
BWO TIMESTAMP---00000 00:00:00.0
BWO---------------(NULL)
RLSDATA
LOG ----------------(NULL)
RECOVERY REQUIRED --(NO)
FRLOG ------------(NULL)
VSAM QUIESCED -------(NO)
RLS IN USE ---------(NO)
0
LOGSTREAMID-----------------------------(NULL)
RECOVERY TIMESTAMP LOCAL-----X'0000000000000000'
RECOVERY TIMESTAMP GMT-------X'0000000000000000'
PROTECTION-PSWD-----(NULL)
RACF----------------(NO)
ASSOCIATIONS
DATA-----DBDSNB.DSNDBD.WWV8301D.TSPROJ.I0001.A001

Step 22c: LISTCAT output (1 of 2)

pr

cl

Ex
2

V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-121

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

0DATA ---------- DBDSNB.DSNDBD.WWV8301D.TSPROJ.I0001.A001


IN-CAT --- ICFCAT.MVSW20.UCAT
HISTORY
DATASET-OWNER----SYSPROG
CREATION--------2011.241
RELEASE----------------2
EXPIRATION------0000.000
ACCOUNT-INFO-----------------------------------(NULL)
PROTECTION-PSWD-----(NULL)
RACF----------------(NO)
ASSOCIATIONS
CLUSTER--DBDSNB.DSNDBC.WWV8301D.TSPROJ.I0001.A001
ATTRIBUTES
KEYLEN-----------------0
AVGLRECL---------------0
BUFSPACE------------8192
CISIZE--------------4096
RKP--------------------0
MAXLRECL---------------0
EXCPEXIT----------(NULL)
CI/CA----------------180
SHROPTNS(3,3)
SPEED
UNIQUE
NOERASE
LINEAR
NOWRITECHK
NOIMBED
NOREPLICAT
UNORDERED
REUSE
NONSPANNED
STATISTICS
REC-TOTAL--------------0
SPLITS-CI--------------0
EXCPS------------------0
REC-DELETED------------0
SPLITS-CA--------------0
EXTENTS----------------1
REC-INSERTED-----------0
FREESPACE-%CI----------0
SYSTEM-TIMESTAMP:
REC-UPDATED------------0
FREESPACE-%CA----------0
X'0000000000000000'
REC-RETRIEVED----------0
FREESPC----------------0
ALLOCATION
SPACE-TYPE------CYLINDER
HI-A-RBA----------737280
SPACE-PRI--------------1
HI-U-RBA-----------61440
SPACE-SEC--------------1
VOLUME
1IDCAMS SYSTEM SERVICES
TIME: 23:25:41
08/29/11
PAGE
3
LISTING FROM CATALOG -- ICFCAT.MVSW20.UCAT
0
VOLSER------------SMS012
PHYREC-SIZE---------4096
HI-A-RBA----------737280
EXTENT-NUMBER----------1
DEVTYPE------X'3010200F'
PHYRECS/TRK-----------12
HI-U-RBA-----------61440
EXTENT-TYPE--------X'40'
VOLFLAG------------PRIME
TRACKS/CA-------------15
EXTENTS:
LOW-CCHH-----X'041B0000'
LOW-RBA----------------0
TRACKS----------------15
HIGH-CCHH----X'041B000E'
HIGH-RBA----------737279
1IDCAMS SYSTEM SERVICES
TIME: 23:25:41
08/29/11
PAGE
4
LISTING FROM CATALOG -- ICFCAT.MVSW20.UCAT
0
THE NUMBER OF ENTRIES PROCESSED WAS:
AIX -------------------0
ALIAS -----------------0
CLUSTER ---------------1
DATA ------------------1
GDG -------------------0
INDEX -----------------0
NONVSAM ---------------0
PAGESPACE -------------0
PATH ------------------0
SPACE -----------------0
USERCATALOG -----------0
TAPELIBRARY -----------0
TAPEVOLUME ------------0
TOTAL -----------------2
0
THE NUMBER OF PROTECTED ENTRIES SUPPRESSED WAS 0
0IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0
1IDCAMS SYSTEM SERVICES
TIME: 23:25:41
08/29/11
PAGE
5
0
0IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0

pr

Step 22c: LISTCAT output (2 of 2)

cl

Ex
Student Exercises

A-122 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Step 23 (optional): Restart a REORG utility

Step 23a: False primary space specification

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+
ALTER INDEX TSOUB01.IXLOCN1
PRIQTY 999999999 ;
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-123

Student Exercises

Step 23b: Trial to reorganize TSLOCN

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.DSNURGT.CNTL
Columns 00
===>
Scroll
***************************** Top of Data ********************
//TSOUB011 JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=TSOUB01,REGION=0M
//*
//*
//UTIL EXEC DSNBUPRC,SYSTEM=DSNB,UID='TSOUB01',UTPROC=''
//*
//**********************************************
//*
//* GENERATING JCL FOR THE REORG TABLESPACE UTILITY
//* DATE: 08/29/11
TIME: 23:36:29
//*
//**********************************************
//*
//DSNUPROC.SORTWK01 DD DSN=TSOUB01.SORTWK01,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTWK02 DD DSN=TSOUB01.SORTWK02,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTWK03 DD DSN=TSOUB01.SORTWK03,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTWK04 DD DSN=TSOUB01.SORTWK04,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSREC DD DSN=TSOUB01.CV83.TSLOCN.REORG.SYSREC1,
//
DISP=(MOD,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSUT1 DD DSN=TSOUB01.SYSUT1,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SORTOUT DD DSN=TSOUB01.SORTOUT,
//
DISP=(MOD,DELETE,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSIN
DD *
REORG TABLESPACE WWV8301D.TSLOCN
//
**************************** Bottom of Data *******

A-124 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Copyright IBM Corp. 1993, 2011

Only the UNLOAD phase has been performed.

1
J E S 2 J O B L O G -- S Y S T E M D I 1 1 -- N O D E M V S D I 1 1
0
23.36.45 JOB00492 ---- MONDAY,
29 AUG 2011 ---23.36.45 JOB00492 IRR010I USERID TSOUB01 IS ASSIGNED TO THIS JOB.
23.36.45 JOB00492 ICH70001I TSOUB01 LAST ACCESS AT 23:25:41 ON MONDAY, AUGUST 29, 2011
23.36.45 JOB00492 $HASP373 TSOUB011 STARTED - INIT 1
- CLASS A - SYS DI11
23.36.48 JOB00492 IEF450I TSOUB011 DSNUPROC UTIL - ABEND=S04E U0000 REASON=00E40305 066
066
TIME=23.36.48
23.36.48 JOB00492 -----TIMINGS (MINS.)----------PAGING COUNTS---23.36.48 JOB00492 -STEPNAME PROCSTEP
RC
EXCP
CONN
TCB
SRB CLOCK
SERV WORKLOAD PAGE SWAP
VIO
SWAPS
0
23.36.48 JOB00492 -UTIL
DSNUPROC *S04E
673
33
.00
.00
.0
147 BATCH
0
0
0
23.36.48 JOB00492 -TSOUB011 ENDED. NAME-TSOUB01 JOB
TOTAL TCB CPU TIME=
.00 TOTAL ELAPSED TIME=
.0
23.36.48 JOB00492 $HASP395 TSOUB011 ENDED
0------ JES2 JOB STATISTICS ------ 29 AUG 2011 JOB EXECUTION DATE
43 CARDS READ
245 SYSOUT PRINT RECORDS
0 SYSOUT PUNCH RECORDS
16 SYSOUT SPOOL KBYTES
0.04 MINUTES EXECUTION TIME
..........
etc
..........
..........
1DSNU000I
241 23:36:45.78 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 23:36:45.80 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
241 23:36:45.81 DSNUGUTC - REORG TABLESPACE WWV8301D.TSLOCN
DSNU252I
241 23:36:45.86 DSNURULD - UNLOAD PHASE STATISTICS - NUMBER OF RECORDS UNLOADED=4 FOR TABLESPACE
WWV8301D.TSLOCN
DSNU250I
241 23:36:45.86 DSNURULD - UNLOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
-DSNT500I
241 23:36:46.13 DSNUGBAC - RESOURCE UNAVAILABLE
REASON 00D70025
TYPE 00000220
NAME DBDSNB.DSNDBC.WWV8301D.IXLOCN1.I0001.A001
-DSNU017I
241 23:36:46.13 DSNUGBAC - UTILITY DATA BASE SERVICES MEMORY EXECUTION ABENDED, REASON=X'00E40305'
CAUSE=X'00D70025'

Step 23b: Partial job output of the unsuccessful REORG TABLESPACE utility

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-125

Student Exercises

The result of the stopped utility

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
SELECT *
FROM LOCATION
---------+---------+---------+---------+---------+---------+---------+---------+
LOCID
ADDRESS
CITY
POSTAL_CODE
COUNTRY
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE610I NUMBER OF ROWS DISPLAYED IS 0
DSNT408I SQLCODE = -904, ERROR: UNSUCCESSFUL EXECUTION CAUSED BY AN
UNAVAILABLE RESOURCE. REASON 00C90082, TYPE OF RESOURCE 00000200, AND
RESOURCE NAME WWV8301D.TSLOCN
DSNT418I SQLSTATE
= 57011 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXRRC SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= 102 13172746 0 13223106 -974970878 12714050 SQL
DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'00000066' X'00C9000A' X'00000000' X'00C9C4C2'
X'C5E32002' X'00C20042' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
-DIS DB(WWV8301D) SPACE(*)

pr

Ex

cl

DSNT360I -DSNB ***********************************


DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV8301D STATUS = RW
DBD LENGTH = 20180
DSNT397I -DSNB
NAME
TYPE PART STATUS
PHYERRLO PHYERRHI CATALOG PIECE
-------- ---- ----- ----------------- -------- -------- -------- ----TSDEPT
TS
0001 RW
TSDEPT
TS
RW
TSEMPL
TS
0001 RW
-THRU
0003
TSEMPL
TS
RW
TSEXCEPT TS
RW,AREO*
TSLOCN
TS
RW,RECP,UTUT
TSPROJ
TS
RW
IXACTY1 IX
RW
IXACTY2 IX
RW
IXDEPT1 IX
L0001 RW
IXDEPT1 IX
L*
RW
IXDEPT2 IX
L0001 RW
IXDEPT2 IX
L*
RW
IXDEPT3 IX
L0001 RW
IXDEPT3 IX
L*
RW
IXEMPL1 IX
0001 RW
-THRU
0003
IXEMPL1 IX
RW
IXEMPL2 IX
L0001 RW
-THRU
0003
IXEMPL2 IX
L*
RW
IXEMPL3 IX
L0001 RW
-THRU
0003
IXEMPL3 IX
L*
RW
A-126 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

IXLOCN1 IX
RW,RBDP,UTUT
IXONPR1 IX
RW
IXONPR2 IX
RW
IXPROJ1 IX
RW
IXPROJ2 IX
RW
IXPROJ3 IX
RW
******* DISPLAY OF DATABASE WWV8301D ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
***

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

Display utility:

DSNU100I -DSNB DSNUGDIS - USERID = TSOUB01


MEMBER =
UTILID = TSOUB01
PROCESSING UTILITY STATEMENT 1
UTILITY = REORG
PHASE = RELOAD
COUNT = 0
NUMBER OF OBJECTS IN LIST = 1
LAST OBJECT STARTED = 1
STATUS = STOPPED
DSN9022I -DSNB DSNUGCCC '-DISPLAY UTILITY' NORMAL COMPLETION
***

The unload phase was successful:

pr

Ex

cl

TSOUB01.CV83.TSLOCN.REORG.SYSREC1
Columns 0
===>
Scroll
***************************** Top of Data *******************
`
DE71083-01AM FICHTENBERG 1
HERRENBERG ...
`
US95141-B4555 BAILEY AVENUE
SAN JOSE
...
`
US95141-C2555 BAILEY AVENUE
SAN JOSE
...
`
US95193-505600 COTTLE ROAD
SAN JOSE
...
**************************** Bottom of Data *****************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-127

Student Exercises

Step 23c: Correct the problem

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+
ALTER INDEX TSOUB01.IXLOCN1
PRIQTY 10 ;
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+

Generate the restart job:


DB2 UTILITIES
===>

SSID: DSNB

Select from the following:

1 FUNCTION ===> EDITJCL


2 JOB ID
===> TSOUB01
3 UTILITY ===> REORG TABLESPACE

(SUBMIT job, EDITJCL, DISPLAY, TERMINATE)


(A unique job identifier string)
(CHECK DATA, CHECK INDEX, CHECK LOB,
COPY, DIAGNOSE, LOAD, MERGE, MODIFY,
QUIESCE, REBUILD, RECOVER, REORG INDEX,
REORG LOB, REORG TABLESPACE, REPORT,
REPAIR, RUNSTATS, STOSPACE, UNLOAD)
4 STATEMENT DATA SET ===> CV83.CNTL(REORGCT2)
5 RESTART ===> NO

(NO, CURRENT, PHASE or PREVIEW)

6 LISTDEF? (YES|NO) ===> NO

TEMPLATE? (YES|NO) ===> NO

7 LIB ==>

(BLANK or DB2 Library name).

pr

Ex

cl

* The data set names panel will be displayed when required by a utility.

A-128 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

The restart job:

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.DSNURGT.CNTL
===>
***************************** Top of Data ******************
//TSOUB011 JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=TSOUB01,REGION=0M
//*
//*
//UTIL EXEC DSNBUPRC,SYSTEM=DSNB,UID='TSOUB01',UTPROC=''
//*
//**********************************************
//*
//* GENERATING JCL FOR THE REORG TABLESPACE UTILITY
//* DATE: 08/29/11
TIME: 23:57:31
//*
//**********************************************
//*
//DSNUPROC.SORTWK01 DD DSN=TSOUB01.SORTWK01,
//
DISP=(MOD,DELETE,CATLG)
//DSNUPROC.SORTWK02 DD DSN=TSOUB01.SORTWK02,
//
DISP=(MOD,DELETE,CATLG)
//DSNUPROC.SORTWK03 DD DSN=TSOUB01.SORTWK03,
//
DISP=(MOD,DELETE,CATLG)
//DSNUPROC.SORTWK04 DD DSN=TSOUB01.SORTWK04,
//
DISP=(MOD,DELETE,CATLG)
//DSNUPROC.SYSREC DD DSN=TSOUB01.CV83.TSLOCN.REORG.SYSREC1,
//
DISP=(MOD,CATLG)
//DSNUPROC.SYSUT1 DD DSN=TSOUB01.SYSUT1,
//
DISP=(MOD,DELETE,CATLG)
//DSNUPROC.SORTOUT DD DSN=TSOUB01.SORTOUT,
//
DISP=(MOD,DELETE,CATLG)
//DSNUPROC.SYSIN
DD *
REORG TABLESPACE WWV8301D.TSLOCN
//
**************************** Bottom of Data ****************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-129

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

..............
etc
..............
..............
1DSNU000I
241 23:57:36.92 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
241 23:57:36.95 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
DSNU021I -DSNB 241 23:57:36.95 DSNUGASU - REORG UTILITY WITH UTILID = TSOUB01 ENDED IN PHASE = RELOAD, WILL ATTEMPT TO
RESTART(CURRENT)
0DSNU050I
241 23:57:36.95 DSNUGUTC - REORG TABLESPACE WWV8301D.TSLOCN
DSNU021I -DSNB 241 23:57:36.95 DSNURFIT - REORG UTILITY WITH UTILID = TSOUB01 ENDED IN PHASE = RELOAD, WILL ATTEMPT TO
RESTART(PHASE)
DSNU304I -DSNB 241 23:57:37.21 DSNURWT - (RE)LOAD PHASE STATISTICS - NUMBER OF RECORDS=4 FOR TABLE TSOUB01.LOCATION
DSNU302I
241 23:57:37.22 DSNURILD - (RE)LOAD PHASE STATISTICS - NUMBER OF INPUT RECORDS PROCESSED=4
DSNU300I
241 23:57:37.22 DSNURILD - (RE)LOAD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU042I
241 23:57:37.22 DSNUGSOR - SORT PHASE STATISTICS NUMBER OF RECORDS=4
ELAPSED TIME=00:00:00
DSNU349I -DSNB 241 23:57:37.36 DSNURBXA - BUILD PHASE STATISTICS - NUMBER OF KEYS=4 FOR INDEX TSOUB01.IXLOCN1
DSNU258I
241 23:57:37.36 DSNURBXD - BUILD PHASE STATISTICS - NUMBER OF INDEXES=1
DSNU259I
241 23:57:37.36 DSNURBXD - BUILD PHASE COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
241 23:57:37.38 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

1
J E S 2 J O B L O G -- S Y S T E M D I 1 1 -- N O D E M V S D I 1 1
0
23.57.36 JOB00493 ---- MONDAY,
29 AUG 2011 ---23.57.36 JOB00493 IRR010I USERID TSOUB01 IS ASSIGNED TO THIS JOB.
23.57.36 JOB00493 ICH70001I TSOUB01 LAST ACCESS AT 23:36:45 ON MONDAY, AUGUST 29, 2011
23.57.36 JOB00493 $HASP373 TSOUB011 STARTED - INIT 1
- CLASS A - SYS DI11
23.57.37 JOB00493 -----TIMINGS (MINS.)----------PAGING COUNTS---23.57.37 JOB00493 -STEPNAME PROCSTEP
RC
EXCP
CONN
TCB
SRB CLOCK
SERV WORKLOAD PAGE SWAP
VIO
SWAPS
0
23.57.37 JOB00493 -UTIL
DSNUPROC
00
694
39
.00
.00
.0
116 BATCH
0
0
0
23.57.37 JOB00493 -TSOUB011 ENDED. NAME-TSOUB01 JOB
TOTAL TCB CPU TIME=
.00 TOTAL ELAPSED TIME=
.0
23.57.37 JOB00493 $HASP395 TSOUB011 ENDED
0------ JES2 JOB STATISTICS ------ 29 AUG 2011 JOB EXECUTION DATE
29 CARDS READ
212 SYSOUT PRINT RECORDS
0 SYSOUT PUNCH RECORDS
14 SYSOUT SPOOL KBYTES
0.00 MINUTES EXECUTION TIME

pr

Step 23c: Partial job output of the successful REORG TABLESPACE utility

cl

Ex
Student Exercises

A-130 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

The second job has performed the RELOAD, SORT, and BUILD phases.
The data in the table space is available again:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DSNT360I -DSNB ***********************************


DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV8301D STATUS = RW
DBD LENGTH = 20180
DSNT397I -DSNB
NAME
TYPE PART STATUS
PHYERRLO PHYERRHI CATALOG PIECE
-------- ---- ----- ----------------- -------- -------- -------- ----TSDEPT
TS
0001 RW
TSDEPT
TS
RW
TSEMPL
TS
0001 RW
-THRU
0003
TSEMPL
TS
RW
TSEXCEPT TS
RW,AREO*
TSLOCN
TS
RW
......
IXLOCN1 IX
RW
......
******* DISPLAY OF DATABASE WWV8301D ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
***

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------...
SELECT * FROM LOCATION
...
---------+---------+---------+---------+---------+---------+---------...
LOCID
ADDRESS
CITY
POSTAL_CODE ...
---------+---------+---------+---------+---------+---------+---------...
DE71083-01 AM FICHTENBERG 1
HERRENBERG
D-71083
...
US95141-B4 555 BAILEY AVENUE
SAN JOSE
CA 95141
...
US95141-C2 555 BAILEY AVENUE
SAN JOSE
CA 95141
...
US95193-50 5600 COTTLE ROAD
SAN JOSE
CA 95193
...
DSNE610I NUMBER OF ROWS DISPLAYED IS 4

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-131

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

A-132 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

Exercise 8: Running COPY and RECOVER

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-133

A-134 DB2 10 for z/OS DB Admin Workshop Part 1

//DSNUPROC.SYSCOPY DD DSN=TSOUB01.CV83.TSEMPL.FIC1A,
//
DISP=(MOD,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSCOPY2 DD DSN=TSOUB01.CV83.TSEMPL.FIC1B,
//
DISP=(MOD,CATLG),
//
SPACE=(16384,(20,20),,,ROUND),
//
UNIT=SYSDA
//DSNUPROC.SYSIN
DD *
COPY TABLESPACE WWV8301D.TSEMPL FULL YES
COPYDDN(,SYSCOPY2)
//

Step 2: Partial COPY job

Enter output data sets for REORG or UNLOAD


7 PUNCHDSN ===>

Enter output data sets for recovery site for COPY, LOAD, or REORG
TABLESPACE:
5 RCPYDSN1 ===>
6 RCPYDSN2 ===>

Enter output data sets for local/current site for COPY, MERGECOPY,
LOAD, or REORG TABLESPACE:
3 COPYDSN ===> CV83.TSEMPL.FIC1A
4 COPYDSN2 ===> CV83.TSEMPL.FIC1B

Enter data set name for LOAD or REORG TABLESPACE:


2 DISCDSN ===>

Enter data set name for LOAD, REORG TABLESPACE, or UNLOAD:


1 RECDSN
===>

===>

SSID:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DATA SET NAMES

Step 2: DB2I Data Set Names Panel for COPY

COPY TABLESPACE WWV8301D.TSEMPL FULL YES


COPYDDN(,SYSCOPY2)

pr

Step 1: COPY statement (full copies)

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

02:34:37.33 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


02:34:37.36 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
02:34:37.36 DSNUGUTC - COPY TABLESPACE WWV8301D.TSEMPL FULL YES COPYDDN(, SYSCOPY2)
02:34:37.44 DSNUBBID - COPY PROCESSED FOR TABLESPACE WWV8301D.TSEMPL
NUMBER OF PAGES=9
AVERAGE PERCENT FREE SPACE PER PAGE = 22.88
PERCENT OF CHANGED PAGES = 1.66
ELAPSED TIME=00:00:00
-DSNB 242 02:34:37.45 DSNUBAFI - DB2 IMAGE COPY SUCCESSFUL FOR TABLESPACE WWV8301D.TSEMPL
242 02:34:37.46 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

242
242
242
242

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

02:43:21.93 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


02:43:21.95 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
02:43:21.96 DSNUGUTC - COPY TABLESPACE WWV8301D.TSEMPL FULL NO COPYDDN(, SYSCOPY2)
02:43:22.01 DSNUBBID - COPY PROCESSED FOR TABLESPACE WWV8301D.TSEMPL
NUMBER OF PAGES=6
AVERAGE PERCENT FREE SPACE PER PAGE = 21.66
PERCENT OF CHANGED PAGES = 0.74
ELAPSED TIME=00:00:00
-DSNB 242 02:43:22.03 DSNUBAFI - DB2 IMAGE COPY SUCCESSFUL FOR TABLESPACE WWV8301D.TSEMPL
242 02:43:22.04 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

242
242
242
242

Step 8: Execute same UPDATE statement as in step 4 above (output not depicted)

DSNU428I
DSNU010I

1DSNU000I
DSNU1044I
0DSNU050I
DSNU400I

Steps 5 - 7: COPY utility output (incremental copies)

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 2
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

UPDATE EMPLOYEE
SET SALARY = SALARY+10000
WHERE EMPNO IN ('000030','000280')

Step 4: Update EMPLOYEE table

DSNU428I
DSNU010I

1DSNU000I
DSNU1044I
0DSNU050I
DSNU400I

Step 3: COPY utility output (full copies)

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-135

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

A-136 DB2 10 for z/OS DB Admin Workshop Part 1

1DSNU000I
242 03:07:49.03 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
242 03:07:49.06 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
242 03:07:49.06 DSNUGUTC - RECOVER TABLESPACE WWV8301D.TSEMPL
DSNU515I
242 03:07:49.07 DSNUCBAL - THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.FIC1A WITH DATE=20110830 AND
TIME=023437
IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL
DSNU515I
242 03:07:49.08 DSNUCBAL - THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.IIC1A WITH DATE=20110830 AND
TIME=024322
IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL
DSNU504I
242 03:07:49.47 DSNUCBMD - MERGE STATISTICS FOR TABLESPACE WWV8301D.TSEMPL
NUMBER OF COPIES=2
NUMBER OF PAGES MERGED=9
ELAPSED TIME=00:00:00
DSNU513I -DSNB 242 03:07:49.48 DSNUCALA - RECOVER UTILITY LOG APPLY RANGE IS RBA 0000066E21DA LRSN 0000066E21DA TO
RBA 0000066E2AA5 LRSN 0000066E2AA5
DSNU1510I
242 03:07:49.49 DSNUCBLA - LOG APPLY PHASE COMPLETE, ELAPSED TIME = 00:00:00
DSNU500I
242 03:07:49.52 DSNUCBDR - RECOVERY COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
242 03:07:49.52 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

Steps 11 to 13: RECOVER utility output

---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+----DBNAME
TSNAME
DSNUM ICTYPE SHRLEVEL ICBACKUP HEX_START_RBA TIMESTAMP
DATA_SET_NAME
---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+----WWV8301D TSEMPL
0 C
000005424454
2011-08-26-02.18.40.986776 WWV8301D.TSEMPL
WWV8301D TSEMPL
1 Z
0000059E01B6
2011-08-27-13.01.37.927432 WWV8301D.TSEMPL
WWV8301D TSEMPL
2 Z
0000059E01B6
2011-08-27-13.01.37.927432 WWV8301D.TSEMPL
WWV8301D TSEMPL
3 Z
0000059E01B6
2011-08-27-13.01.37.927432 WWV8301D.TSEMPL
WWV8301D TSEMPL
0 F
R
00000667AD5A
2011-08-30-02.34.37.449155 TSOUB01.CV83.TSEMPL.FIC1A
WWV8301D TSEMPL
0 F
R
LB
00000667AD5A
2011-08-30-02.34.37.449448 TSOUB01.CV83.TSEMPL.FIC1B
WWV8301D TSEMPL
0 I
R
0000066D6F47
2011-08-30-02.43.22.027921 TSOUB01.CV83.TSEMPL.IIC1A
WWV8301D TSEMPL
0 I
R
LB
0000066D6F47
2011-08-30-02.43.22.028189 TSOUB01.CV83.TSEMPL.IIC1B
DSNE610I NUMBER OF ROWS DISPLAYED IS 8
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100

---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+----SELECT DBNAME,TSNAME,DSNUM,ICTYPE,SHRLEVEL,ICBACKUP,
HEX(START_RBA) AS HEX_START_RBA,TIMESTAMP,
SUBSTR(DSNAME,1,25) AS DATA_SET_NAME
FROM SYSIBM.SYSCOPY
WHERE DBNAME = 'WWV8301D'
AND TSNAME = 'TSEMPL'
ORDER BY TIMESTAMP,ICBACKUP,DSNUM
WITH UR ;

pr

Steps 9 to 10: Query SYSCOPY catalog table

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Question related to recovery:


Step 14: Which image copies are used by the RECOVER utility?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.TSEMPL.FIC1A
TSOUB01.CV83.TSEMPL.IIC1A

Step 15: Why must the RECOVER utility apply log records after restoring
the image copies?
The RECOVER utility must apply the log records which represent the update
performed after the incremental image copies were taken.

Step 16: Delete the primary incremental image copy


TSOUB01.CV83.TSEMPL.IIC1A in 3.4:
d

TSOUB01.CV83.TSEMPL.FIC1A
TSOUB01.CV83.TSEMPL.FIC1B
TSOUB01.CV83.TSEMPL.IIC1A
TSOUB01.CV83.TSEMPL.IIC1B
TSOUB01.CV83.TSLOCN.DATA

Result:

Deleted

pr

Ex

cl

TSOUB01.CV83.TSEMPL.FIC1A
TSOUB01.CV83.TSEMPL.FIC1B
TSOUB01.CV83.TSEMPL.IIC1A
TSOUB01.CV83.TSEMPL.IIC1B
TSOUB01.CV83.TSLOCN.DATA
TSOUB01.CV83.TSLOCN.DISCARD

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-137

DSNUGUTC
DSNUGTIS
DSNUGUTC
DSNUCBAL

- OUTPUT START FOR UTILITY, UTILID = TSOUB01


- PROCESSING SYSIN AS EBCDIC
- RECOVER TABLESPACE WWV8301D.TSEMPL
- THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.FIC1A WITH DATE=20110830 AND

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

03:12:24.20
03:12:24.22
03:12:24.23
03:12:24.24

A-138 DB2 10 for z/OS DB Admin Workshop Part 1

The dynamic allocaion of the primary incremental copy fails.


Therefore DB2 allocates the backup incremental copy.

Step 18: Response of the RECOVER utility

IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL


DSNU515I
242 03:12:24.25 DSNUCBAL - THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.IIC1A WITH DATE=20110830 AND
TIME=024322
IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL
DSNU030I
242 03:12:24.25 DSNUCBAL - UNABLE TO ALLOCATE TSOUB01.CV83.TSEMPL.IIC1A, RC=4, CODE=X'17080002'
DSNU541I
242 03:12:24.25 DSNUCBAL - UNABLE TO ALLOCATE THE PRIMARY COPY DATASET
TSOUB01.CV83.TSEMPL.IIC1A, BACKUP COPY IS USED
DSNU515I
242 03:12:24.25 DSNUCBAL - THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.IIC1B WITH DATE=20110830 AND
TIME=024322
IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL
DSNU504I
242 03:12:24.61 DSNUCBMD - MERGE STATISTICS FOR TABLESPACE WWV8301D.TSEMPL
NUMBER OF COPIES=2
NUMBER OF PAGES MERGED=9
ELAPSED TIME=00:00:00
DSNU513I -DSNB 242 03:12:24.62 DSNUCALA - RECOVER UTILITY LOG APPLY RANGE IS RBA 0000066E21DA LRSN 0000066E21DA TO
RBA 0000066E2AA5 LRSN 0000066E2AA5
DSNU1510I
242 03:12:24.62 DSNUCBLA - LOG APPLY PHASE COMPLETE, ELAPSED TIME = 00:00:00
DSNU500I
242 03:12:24.65 DSNUCBDR - RECOVERY COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
242 03:12:24.66 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

242
242
242
242

pr

1DSNU000I
DSNU1044I
0DSNU050I
DSNU515I
TIME=023437

Step 17: Execute the same RECOVER job as in step 11-13; output

cl

Ex
Student Exercises

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Copyright IBM Corp. 1993, 2011

242
242
242
242

03:16:24.34
03:16:24.36
03:16:24.37
03:16:24.38

DSNUGUTC
DSNUGTIS
DSNUGUTC
DSNUCBAL

- OUTPUT START FOR UTILITY, UTILID = TSOUB01


- PROCESSING SYSIN AS EBCDIC
- RECOVER TABLESPACE WWV8301D.TSEMPL
- THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.FIC1A WITH DATE=20110830 AND

IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL


DSNU515I
242 03:16:24.39 DSNUCBAL - THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.IIC1A WITH DATE=20110830 AND
TIME=024322
IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL
DSNU030I
242 03:16:24.39 DSNUCBAL - UNABLE TO ALLOCATE TSOUB01.CV83.TSEMPL.IIC1A, RC=4, CODE=X'17080002'
DSNU541I
242 03:16:24.39 DSNUCBAL - UNABLE TO ALLOCATE THE PRIMARY COPY DATASET
TSOUB01.CV83.TSEMPL.IIC1A, BACKUP COPY IS USED
DSNU515I
242 03:16:24.39 DSNUCBAL - THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.IIC1B WITH DATE=20110830 AND
TIME=024322
IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL
DSNU030I
242 03:16:24.39 DSNUCBAL - UNABLE TO ALLOCATE TSOUB01.CV83.TSEMPL.IIC1B, RC=4, CODE=X'17080002'
DSNU504I
242 03:16:24.75 DSNUCBMD - MERGE STATISTICS FOR TABLESPACE WWV8301D.TSEMPL
NUMBER OF COPIES=1
NUMBER OF PAGES MERGED=9
ELAPSED TIME=00:00:00
DSNU513I -DSNB 242 03:16:24.76 DSNUCALA - RECOVER UTILITY LOG APPLY RANGE IS RBA 000006688A00 LRSN 000006688A00 TO
RBA 000006689563 LRSN 000006689563
DSNU513I -DSNB 242 03:16:24.76 DSNUCALA - RECOVER UTILITY LOG APPLY RANGE IS RBA 0000066E21DA LRSN 0000066E21DA TO
RBA 0000066E2AA5 LRSN 0000066E2AA5
DSNU1510I
242 03:16:24.77 DSNUCBLA - LOG APPLY PHASE COMPLETE, ELAPSED TIME = 00:00:00
DSNU500I
242 03:16:24.79 DSNUCBDR - RECOVERY COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
242 03:16:24.80 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

1DSNU000I
DSNU1044I
0DSNU050I
DSNU515I
TIME=023437

Step 20: Execute the same RECOVER job as in step 11-13; output

Similar to step 16

Step 19: Delete the backup incremental copy, too

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-139

Student Exercises

Question related to recovery after deleting backup incremental copy:


Step 21: Response of the recover utility?
The recovery utility must rely on the full image copies, as no incremental copy
exists.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Step 22: Why must the RECOVER utility apply an additional range of log
records?
The additional range of log records represent the update performed before the
incremental image copies were taken.

Optional lab:

Step 23a: Copy the first partition only of table space TSEMPL

********************************* TOP OF DATA **********************************


DSNU000I
242 04:22:51.64 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
242 04:22:51.67 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
DSNU050I
242 04:22:51.67 DSNUGUTC - COPY TABLESPACE WWV8301D.TSEMPL DSNUM 1
DSNU400I
242 04:22:51.72 DSNUBBID - COPY PROCESSED FOR TABLESPACE WWV8301D.TSEMPL DSNUM 1
NUMBER OF PAGES=3
AVERAGE PERCENT FREE SPACE PER PAGE = 20.66
PERCENT OF CHANGED PAGES = 33.33
ELAPSED TIME=00:00:00
DSNU428I -DSNB 242 04:22:51.73 DSNUBAFI - DB2 IMAGE COPY SUCCESSFUL FOR TABLESPACE
WWV8301D.TSEMPL DSNUM 1
DSNU010I
242 04:22:51.74 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

pr

Ex

cl

******************************** BOTTOM OF DATA ********************************

A-140 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 23b: LISTCAT job

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.CNTL(L8LISTC) - 01.00
===>
***************************** Top of Data **********************
//TSOUB01L JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=&SYSUID,REGION=0M
//*******************************************************************
//*
*
//*******************************************************************
//*
//* LISTCAT
//*
//IDCAMS
EXEC PGM=IDCAMS,REGION=2500K
//SYSPRINT DD SYSOUT=*
//SYSIN
DD *
LISTCAT LEVEL (DBDSNB.*.WWV8301D.TSEMPL) ALL
//
**************************** Bottom of Data ********************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-141

PAGE

PAGE

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1IDCAMS SYSTEM SERVICES


TIME: 04:28:00
08/30/11
0
LISTCAT LEVEL (DBDSNB.*.WWV8301D.TSEMPL) ALL
1IDCAMS SYSTEM SERVICES
TIME: 04:28:00
08/30/11
LISTING FROM CATALOG -- ICFCAT.MVSW20.UCAT
0CLUSTER ------- DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001
IN-CAT --- ICFCAT.MVSW20.UCAT
HISTORY
DATASET-OWNER----SYSPROG
CREATION--------2011.242
RELEASE----------------2
EXPIRATION------0000.000
SMSDATA
STORAGECLASS --------DB2
MANAGEMENTCLASS-STANDARD
DATACLASS --------(NULL)
LBACKUP ---0000.000.0000
CA-RECLAIM----------(NO)
EATTR-------------(NULL)
BWO STATUS------00000000
BWO TIMESTAMP---00000 00:00:00.0
BWO---------------(NULL)
RLSDATA
LOG ----------------(NULL)
RECOVERY REQUIRED --(NO)
FRLOG ------------(NULL)
VSAM QUIESCED -------(NO)
RLS IN USE ---------(NO)
0
LOGSTREAMID-----------------------------(NULL)
RECOVERY TIMESTAMP LOCAL-----X'0000000000000000'
RECOVERY TIMESTAMP GMT-------X'0000000000000000'
PROTECTION-PSWD-----(NULL)
RACF----------------(NO)
ASSOCIATIONS
DATA-----DBDSNB.DSNDBD.WWV8301D.TSEMPL.I0001.A001

pr

Step 23b: Partial LISTCAT output for TSEMPL, 1 of 2

cl

Ex
2

Student Exercises

A-142 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

0DATA ---------- DBDSNB.DSNDBD.WWV8301D.TSEMPL.I0001.A001


IN-CAT --- ICFCAT.MVSW20.UCAT
HISTORY
DATASET-OWNER----SYSPROG
CREATION--------2011.242
RELEASE----------------2
EXPIRATION------0000.000
ACCOUNT-INFO-----------------------------------(NULL)
PROTECTION-PSWD-----(NULL)
RACF----------------(NO)
ASSOCIATIONS
CLUSTER--DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001
ATTRIBUTES
KEYLEN-----------------0
AVGLRECL---------------0
BUFSPACE------------8192
CISIZE--------------4096
RKP--------------------0
MAXLRECL---------------0
EXCPEXIT----------(NULL)
CI/CA----------------180
SHROPTNS(3,3)
SPEED
UNIQUE
NOERASE
LINEAR
NOWRITECHK
NOIMBED
NOREPLICAT
UNORDERED
REUSE
NONSPANNED
STATISTICS
REC-TOTAL--------------0
SPLITS-CI--------------0
EXCPS------------------0
REC-DELETED------------0
SPLITS-CA--------------0
EXTENTS----------------1
REC-INSERTED-----------0
FREESPACE-%CI----------0
SYSTEM-TIMESTAMP:
REC-UPDATED------------0
FREESPACE-%CA----------0
X'0000000000000000'
REC-RETRIEVED----------0
FREESPC----------------0
ALLOCATION
SPACE-TYPE------CYLINDER
HI-A-RBA----------737280
SPACE-PRI--------------1
HI-U-RBA-----------12288
SPACE-SEC--------------1
VOLUME
1IDCAMS SYSTEM SERVICES
TIME: 04:28:00
08/30/11
PAGE
3
LISTING FROM CATALOG -- ICFCAT.MVSW20.UCAT
0
VOLSER------------SMS012
PHYREC-SIZE---------4096
HI-A-RBA----------737280
EXTENT-NUMBER----------1
DEVTYPE------X'3010200F'
PHYRECS/TRK-----------12
HI-U-RBA-----------12288
EXTENT-TYPE--------X'40'
VOLFLAG------------PRIME
TRACKS/CA-------------15
EXTENTS:
LOW-CCHH-----X'04180000'
LOW-RBA----------------0
TRACKS----------------15
HIGH-CCHH----X'0418000E'
HIGH-RBA----------737279
etc (DATA INFORMATION of other partitions)

Step 23b: Partial LISTCAT output for TSEMPL, 2 of 2

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-143

Student Exercises

All the partitions are on volume SMS012


(the last two partitions are not depicted in the partial output above).

Step 23c: Trial to delete the VSAM cluster

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.CNTL(L8DELC) - 01.00
Columns 0000
===>
Scroll ==
***************************** Top of Data **********************
//TSOUB01D JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=&SYSUID,REGION=0M
//*******************************************************************
//*
*
//*******************************************************************
//*
//* DELETE VSAM CLUSTER
//*
//IDCAMS
EXEC PGM=IDCAMS,REGION=2500K
//SYSPRINT DD SYSOUT=*
//SYSIN
DD *
DEL DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001 CL
//
**************************** Bottom of Data ********************

Result:

********************************* TOP OF DATA **********************************


1IDCAMS SYSTEM SERVICES
TIME: 04:44:03
PAGE
1
0
DEL DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001 CL
0IKJ56225I DATA SET DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001 ALREADY IN
IKJ56225I USE, TRY LATER
IKJ56225I DATA SET IS ALLOCATED TO ANOTHER JOB OR USER
IDC0551I ** ENTRY DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001 NOT DELETED
0IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 8
0
0IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 8

08/30/11

cl

******************************** BOTTOM OF DATA ********************************

pr

Ex

Data set is in use - by DB2.

A-144 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 23d: Stop partition 1 via job (rather than DB2I)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

TSOUB01.CV83.CNTL(L8DB2CMD) - 01.01
Col
===>
***************************** Top of Data *************
//TSOUB011 JOB 1CV83G26,'TSOUB01 JOB
',MSGLEVEL=(1,1),
//
CLASS=A,MSGCLASS=Q,NOTIFY=&SYSUID,REGION=0M
//*******************************************************************
//*
*
//*******************************************************************
//DB2CMD
EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT)
//STEPLIB DD DSN=DBDSNB.DB2A10.SDSNEXIT,DISP=SHR
//
DD DSN=DBDSNB.DB2A10.SDSNLOAD,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT
DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DSNB)
-STOP
DATABASE(WWV8301D) SPACENAM(TSEMPL) PART(1)

-DISPLAY DATABASE(WWV8301D) SPACENAM(TSEMPL)


END

//
**************************** Bottom of Data ***********

Result:

pr

Ex

cl

********************************* TOP OF DATA **************************


1READY
DSN SYSTEM(DSNB)
DSN
-STOP
DATABASE(WWV8301D) SPACENAM(TSEMPL) PART(1)
DSN9022I -DSNB DSNTDDIS 'STOP DATABASE' NORMAL COMPLETION
DSN
-DISPLAY DATABASE(WWV8301D) SPACENAM(TSEMPL)
DSNT360I -DSNB ***********************************
DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV8301D STATUS = RW
DBD LENGTH = 20180
DSNT397I -DSNB
NAME
TYPE PART STATUS
PHYERRLO PHYERRHI CATALOG PIECE
-------- ---- ----- ----------------- -------- -------- -------- ----TSEMPL
TS
0001 STOP
TSEMPL
TS
0002 RW
-THRU
0003
TSEMPL
TS
STOP
******* DISPLAY OF DATABASE WWV8301D ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
DSN
END
READY
END
******************************** BOTTOM OF DATA ************************

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-145

Student Exercises

Same delete job as above, result:


********************************* TOP OF DATA **********************************
IDCAMS SYSTEM SERVICES
TIME: 05:12:28

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DEL DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001 CL
IDC0550I ENTRY (D) DBDSNB.DSNDBD.WWV8301D.TSEMPL.I0001.A001 DELETED
IDC0550I ENTRY (C) DBDSNB.DSNDBC.WWV8301D.TSEMPL.I0001.A001 DELETED
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0

IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0


******************************** BOTTOM OF DATA ********************************

pr

Ex

cl

This way we have simulated an I/O error for partition 1.

A-146 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

Step 23e: We pretend that the defective volume has been replaced.

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

EXempty

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-147

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

1READY
DSN SYSTEM(DSNB)
DSN
-START
DATABASE(WWV8301D) SPACENAM(TSEMPL) PART(1)
DSN9022I -DSNB DSNTDDIS 'START DATABASE' NORMAL COMPLETION
DSN
-DISPLAY DATABASE(WWV8301D) SPACENAM(TSEMPL)
DSNT360I -DSNB ***********************************
DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV8301D STATUS = RW
DBD LENGTH = 20180
DSNT397I -DSNB
NAME
TYPE PART STATUS
PHYERRLO PHYERRHI CATALOG PIECE
-------- ---- ----- ----------------- -------- -------- -------- ----TSEMPL
TS
0001 RW
-THRU
0003
TSEMPL
TS
RW
******* DISPLAY OF DATABASE WWV8301D ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
DSN
END
READY
END

Start the partition:

Reason C90081 indicates: Object stopped.

********************************* TOP OF DATA **********************************


1DSNU000I
242 05:15:29.51 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
242 05:15:29.54 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
242 05:15:29.54 DSNUGUTC - RECOVER TABLESPACE WWV8301D.TSEMPL DSNUM 1
DSNU590I -DSNB 242 05:15:29.55 DSNUGDTC - RESOURCE NOT AVAILABLE, REASON=X'00C90081', ON WWV8301D.TSEMPL PROHIBITS
PROCESSING
DSNU500I
242 05:15:29.55 DSNUCBDR - RECOVERY COMPLETE, ELAPSED TIME=00:00:00
DSNU012I
242 05:15:29.55 DSNUGBAC - UTILITY EXECUTION TERMINATED, HIGHEST RETURN CODE=8
******************************** BOTTOM OF DATA ********************************

pr

Step 23f: First trial to RECOVER ....DSNUM 1

cl

Ex
Student Exercises

A-148 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Copyright IBM Corp. 1993, 2011

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

242
242
242
242

05:54:56.54
05:54:56.57
05:54:56.58
05:54:56.59

DSNUGUTC
DSNUGTIS
DSNUGUTC
DSNUCBAL

- OUTPUT START FOR UTILITY, UTILID = TSOUB01


- PROCESSING SYSIN AS EBCDIC
- RECOVER TABLESPACE WWV8301D.TSEMPL DSNUM 1
- THE IMAGE COPY DATA SET TSOUB01.CV83.TSEMPL.PART1.FCOPY1 WITH DATE=20110830 AND

Copyright IBM Corp. 1993, 2011

Note: The copy data set for the single partition was used.

DSNU504I

IS PARTICIPATING IN RECOVERY OF TABLESPACE WWV8301D.TSEMPL DSNUM 1


242 05:54:56.68 DSNUCBMD - MERGE STATISTICS FOR TABLESPACE WWV8301D.TSEMPL DSNUM 1 NUMBER OF COPIES=1
NUMBER OF PAGES MERGED=3
ELAPSED TIME=00:00:00
DSNU1511I -DSNB 242 05:54:56.68 DSNUCALA - FAST LOG APPLY WAS NOT USED FOR RECOVERY
DSNU1510I
242 05:54:56.68 DSNUCBLA - LOG APPLY PHASE COMPLETE, ELAPSED TIME = 00:00:00
DSNU500I
242 05:54:56.70 DSNUCBDR - RECOVERY COMPLETE, ELAPSED TIME=00:00:00
DSNU010I
242 05:54:56.70 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

1DSNU000I
DSNU1044I
0DSNU050I
DSNU515I
TIME=042251

Step 23f: Second trial to RECOVER ....DSNUM 1

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

Appendix A. Exercise solutions

A-149

Student Exercises

Step 24: Why stop and restart TSDEPT before second DSN1PRNT?
The data is externalized from buffer pool to disk asynchronously, even if an update is
committed. When the table space is stopped, the table space is brought back to currency.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

When performing a DSN1PRNT, an INSERT, and a second DSN1PRNT right away, you
may observe that the INSERT is not reflected in the output of the second DSN1PRNT job.

Step 25: Clean up the system

1. Execute the REPORT RECOVERY utility.

It displays SYSCOPY entries, SYSLGRNX entries, and archive log information.


2. Execute the MODIFY RECOVERY utility.

Depending on the option and parameter you use, it deletes the requested records from
SYSCOPY and some records from SYSLGRNX. If you specified, for example, AGE(*),
the tablespace is set in COPY PENDING.
3. Execute the REPORT RECOVERY utility again.

You see fewer SYSCOPY, SYSLGRNX entries and less information about archive logs.
It is possible that DB2 has no data at all to report.

pr

Ex

cl

See below for sample utility output for the three items in Step 25.

A-150 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Copyright IBM Corp. 1993, 2011

-DSNB 242 06:00:41.42 DSNUPSUM - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN SUMMARY


-DSNB 242 06:00:41.42 DSNUPSUM - NO DATA TO BE REPORTED

-DSNB 242 06:00:41.42 DSNUPPLR - SYSLGRNX


UCTIME
START RBA
STOP RBA
02184055
00000541D8FD
00000541EAAF
04533119
00000549E000
0000054A0C2C
07525672
0000055DBD4B
0000055E41D4
23364598
0000065B1A9B
0000065B3C40
23573706
0000065D0EFF
0000065D30FB
23573717
0000065D45D8
0000065E5522

DSNU586I
DSNU588I

DSNU583I
UCDATE
082611
082611
082611
082911
082911
082911

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

DSNU580I
DSNU010I

242 06:00:41.42 DSNUPORT - REPORT UTILITY COMPLETE - ELAPSED TIME=00:00:00


242 06:00:41.43 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

-DSNB 242 06:00:41.42 DSNUPPBK - REPORT RECOVERY SYSTEM LEVEL BACKUPS


-DSNB 242 06:00:41.42 DSNUPPBK - NO DATA TO BE REPORTED

DSNU598I
DSNU588I

DSNU589I

-DSNB 242 06:00:41.42 DSNUPSUM - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN SUMMARY


ARCHLOG1 BSDS VOLSER(S)
SMS013
-DSNB 242 06:00:41.42 DSNUPREC - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN COMPLETE

DSNU586I

DSNU584I -DSNB 242 06:00:41.42 DSNUPPBS - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN ARCHLOG1 BSDS VOLUMES
START TIME
END TIME
START RBA
END RBA
UNIT VOLSER
DATA SET NAME
20112341848179 20112412111264 000004380000 00000653FFFF SYSDA SMS013 DBDSNB.ARCHLOG1.A0000003

ROWS FROM REPORT RECOVERY FOR TABLESPACE WWV8301D.TSLOCN


START LRSN
STOP LRSN
PARTITION
MEMBER ID
C846F72AAAE2
C846F72AB632
0000
0000
C84719C6E973
C8471C37B2D9
0000
0000
C84741E1B9C8
C84741E1C486
0000
0000
C84BDA6FFB4E
C84BDA6FFE6C
0000
0000
*
C84BDF191ACA
C84BDF191DD3
0000
0000
*
C84BDF1934C6
C84BDF193D3A
0000
0000
*

2011-08-29-23.57.37.198074, IC TYPE = *X*, SHR LVL = , DSNUM


= 0000, START LRSN =0000065A967E
,
IC BACK =
,
STYPE
= , FILE SEQ = 0000, PIT LRSN = 000000000000
0000,
HIGH DSNUM = 0000,
OLDEST VERSION = 0000,
LOGICAL PART = 0000,
LOGGED = Y,
TTYPE =
TSOUB011,
AUTHID =
TSOUB01 ,
COPYPAGESF = -1.0E+00
-1.0E+00
,
CPAGESF = -1.0E+00
WWV8301D.TSLOCN
, MEMBER NAME =
, INSTANCE = 01, RELCREATED = O

=
=
=
=
=
=

TIMESTAMP
DEV TYPE
LOW DSNUM
JOBNAME
NPAGESF
DSNAME

2011-08-26-07.52.56.678505, IC TYPE = *Z*, SHR LVL = , DSNUM


= 0000, START LRSN =0000055D0F4A
,
IC BACK =
,
STYPE
= , FILE SEQ = 0000, PIT LRSN = 000000000000
0000,
HIGH DSNUM = 0000,
OLDEST VERSION = 0001,
LOGICAL PART = 0000,
LOGGED = Y,
TTYPE =
TSOUB011,
AUTHID =
TSOUB01 ,
COPYPAGESF = -1.0E+00
-1.0E+00
,
CPAGESF = -1.0E+00
WWV8301D.TSLOCN
, MEMBER NAME =
, INSTANCE = 01, RELCREATED = O

=
=
=
=
=
=

TIMESTAMP
DEV TYPE
LOW DSNUM
JOBNAME
NPAGESF
DSNAME

1DSNU000I
242 06:00:41.38 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
242 06:00:41.41 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
242 06:00:41.41 DSNUGUTC - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN
DSNU581I -DSNB 242 06:00:41.42 DSNUPREC - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN
DSNU593I -DSNB 242 06:00:41.42 DSNUPREC - REPORT RECOVERY ENVIRONMENT RECORD:
MINIMUM
RBA: 000000000000
MAXIMUM
RBA: FFFFFFFFFFFF
MIGRATING RBA: 000000000000
DSNU582I -DSNB 242 06:00:41.42 DSNUPPCP - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN SYSCOPY ROWS
AND SYSTEM LEVEL BACKUPS
TIMESTAMP = 2011-08-26-02.18.40.182634, IC TYPE = *C*, SHR LVL = , DSNUM
= 0000, START LRSN =00000541C7BC
DEV TYPE =
,
IC BACK =
,
STYPE
= L, FILE SEQ = 0000, PIT LRSN = 000000000000
LOW DSNUM = 0000,
HIGH DSNUM = 0000,
OLDEST VERSION = 0000,
LOGICAL PART = 0000,
LOGGED = Y,
TTYPE =
JOBNAME
=
,
AUTHID =
,
COPYPAGESF = -1.0E+00
NPAGESF
= -1.0E+00
,
CPAGESF = -1.0E+00
DSNAME
= WWV8301D.TSLOCN
, MEMBER NAME =
, INSTANCE = 01, RELCREATED = O

Step 25a: REPORT utility output

pr

cl

Ex
V5.4.0.3
Student Exercises

EXempty

Appendix A. Exercise solutions

A-151

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

A-152 DB2 10 for z/OS DB Admin Workshop Part 1

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

-DSNB 242 13:29:58.60 DSNUPPBS - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN ARCHLOG1 BSDS VOLUMES
-DSNB 242 13:29:58.60 DSNUPPBS - NO DATA TO BE REPORTED

-DSNB 242 13:29:58.60 DSNUPSUM - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN SUMMARY


-DSNB 242 13:29:58.60 DSNUPSUM - NO DATA TO BE REPORTED
-DSNB 242 13:29:58.60 DSNUPREC - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN COMPLETE

-DSNB 242 13:29:58.60 DSNUPPBK - REPORT RECOVERY SYSTEM LEVEL BACKUPS


-DSNB 242 13:29:58.60 DSNUPPBK - NO DATA TO BE REPORTED

DSNU584I
DSNU588I

DSNU586I
DSNU588I
DSNU589I

DSNU598I
DSNU588I

242 13:29:58.60 DSNUPORT - REPORT UTILITY COMPLETE - ELAPSED TIME=00:00:00


242 13:29:58.60 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=0

-DSNB 242 13:29:58.60 DSNUPPLR - SYSLGRNX ROWS FROM REPORT RECOVERY FOR TABLESPACE WWV8301D.TSLOCN
-DSNB 242 13:29:58.60 DSNUPPLR - NO DATA TO BE REPORTED

DSNU583I
DSNU588I

DSNU580I
DSNU010I

-DSNB 242 13:29:58.60 DSNUPSUM - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN SUMMARY


-DSNB 242 13:29:58.60 DSNUPSUM - NO DATA TO BE REPORTED

DSNU586I
DSNU588I

1DSNU000I
242 13:29:58.56 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01
DSNU1044I
242 13:29:58.59 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
0DSNU050I
242 13:29:58.59 DSNUGUTC - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN
DSNU581I -DSNB 242 13:29:58.59 DSNUPREC - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN
DSNU593I -DSNB 242 13:29:58.60 DSNUPREC - REPORT RECOVERY ENVIRONMENT RECORD:
MINIMUM
RBA: 000000000000
MAXIMUM
RBA: FFFFFFFFFFFF
MIGRATING RBA: 000000000000
DSNU582I -DSNB 242 13:29:58.60 DSNUPPCP - REPORT RECOVERY TABLESPACE WWV8301D.TSLOCN SYSCOPY ROWS
AND SYSTEM LEVEL BACKUPS
TIMESTAMP = 2011-08-30-13.25.36.400287, IC TYPE = *M*, SHR LVL = , DSNUM
= 0000, START LRSN =0000065E5522
DEV TYPE =
,
IC BACK =
,
STYPE
= R, FILE SEQ = 0000, PIT LRSN = 0000068D9A7F
LOW DSNUM = 0000,
HIGH DSNUM = 0000,
OLDEST VERSION = 0001,
LOGICAL PART = 0000,
LOGGED = Y,
TTYPE =
JOBNAME
= TSOUB011,
AUTHID =
TSOUB01 ,
COPYPAGESF = -1.0E+00
NPAGESF
= -1.0E+00
,
CPAGESF = -1.0E+00
DSNAME
= WWV8301D.TSLOCN
, MEMBER NAME =
, INSTANCE = 01, RELCREATED = O

Step 25c: REPORT utility output

DSNU381I
DSNU575I
DSNU010I

13:25:36.35 DSNUGUTC - OUTPUT START FOR UTILITY, UTILID = TSOUB01


13:25:36.38 DSNUGTIS - PROCESSING SYSIN AS EBCDIC
13:25:36.38 DSNUGUTC - MODIFY RECOVERY TABLESPACE WWV8301D.TSLOCN DELETE DATE 20110830
242 13:25:36.40 DSNUMDEL - ALL LOCALSITE SYSCOPY RECORDS FOR TABLESPACE= WWV8301D.TSLOCN
HAVE BEEN DELETED
-DSNB 242 13:25:36.40 DSNUGSRX - TABLESPACE WWV8301D.TSLOCN IS IN COPY PENDING
-DSNB 242 13:25:36.40 DSNUMODA - MODIFY COMPLETED SUCCESSFULLY
242 13:25:36.41 DSNUGBAC - UTILITY EXECUTION COMPLETE, HIGHEST RETURN CODE=4

1DSNU000I
242
DSNU1044I
242
0DSNU050I
242
DSNU572I -DSNB

pr

Step 25b: MODIFY utility output

cl

Ex
Student Exercises

Copyright IBM Corp. 1993, 2011

V5.4.0.3
Student Exercises

EXempty

Exercise 9: Security
Steps 1 to 4: Privileges on tables you do not own
SELECT * FROM TSOUB02.EMPLOYEE

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -551, ERROR: TSOUB01 DOES NOT HAVE THE PRIVILEGE TO PERFORM
OPERATION SELECT ON OBJECT TSOUB02.EMPLOYEE
DSNT418I SQLSTATE
= 42501 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXOSC SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= -100 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'FFFFFF9C' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Initially, you do not have SELECT privilege on your neighbors EMPLOYEE table. After
your neighbor grants you SELECT privilege via: GRANT SELECT ON EMPLOYEE TO TSOUB01,
you are able to select data from their table. However, you cannot delete data because you
do not have DELETE privilege.

RACF groups and current SQLID

Step 5: Determine primary authorization id and current SQLID

Ex

cl

SELECT SUBSTR(USER,1,15) AS PRIMARY_AUTHID,


SUBSTR(CURRENT SQLID,1,15) AS CURRENT_SQLID
FROM SYSIBM.SYSDUMMY1
---------+---------+---------+--PRIMARY_AUTHID
CURRENT_SQLID
---------+---------+---------+--TSOUB01
TSOUB01
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

pr

It is not possible to determine your Secondary Authids using SQL.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-153

Student Exercises

Step 6: Sample result of: ===> TSO LISTUSER (or TSO LU)

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

USER=TSOUB01 NAME=CV83 STUDENT


OWNER=WWCV83ST CREATED=11.235
DEFAULT-GROUP=WWCV83ST PASSDATE=11.236 PASS-INTERVAL=N/A PHRASEDATE=N/A
ATTRIBUTES=NONE
REVOKE DATE=NONE
RESUME DATE=NONE
LAST-ACCESS=11.243/00:27:46
CLASS AUTHORIZATIONS=NONE
NO-INSTALLATION-DATA
NO-MODEL-NAME
LOGON ALLOWED
(DAYS)
(TIME)
--------------------------------------------ANYDAY
ANYTIME
GROUP=WWCV83ST AUTH=USE
CONNECT-OWNER=WWCV83ST CONNECT-DATE=11.235
CONNECTS=
75 UACC=NONE
LAST-CONNECT=11.243/00:27:46
CONNECT ATTRIBUTES=NONE
REVOKE DATE=NONE
RESUME DATE=NONE
GROUP=STUDENT
AUTH=USE
CONNECT-OWNER=SYSPROG
CONNECT-DATE=11.235
CONNECTS=
00 UACC=NONE
LAST-CONNECT=UNKNOWN
CONNECT ATTRIBUTES=NONE
REVOKE DATE=NONE
RESUME DATE=NONE
SECURITY-LEVEL=NONE SPECIFIED
CATEGORY-AUTHORIZATION
NONE SPECIFIED
SECURITY-LABEL=NONE SPECIFIED
***

The default group is: WWCV83ST.

Step 7: Changing your current SQLID


SET CURRENT SQLID = 'WWCV83ST';

cl

---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Step 8: Verify this change

pr

Ex

SELECT SUBSTR(USER,1,15) AS PRIMARY_AUTHID,


SUBSTR(CURRENT SQLID,1,15) AS CURRENT_SQLID
FROM SYSIBM.SYSDUMMY1
---------+---------+---------+-PRIMARY_AUTHID
CURRENT_SQLID
---------+---------+---------+TSOUB01
WWCV83ST
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

A-154 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 9: Determining privileges held by authorization IDs

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+--SELECT SUBSTR(NAME,1,8) AS NAME,SUBSTR(CREATOR,1,8) AS CREATOR,


SUBSTR(CREATEDBY,1,8) AS CREATEDBY
FROM SYSIBM.SYSDATABASE
WHERE NAME = 'WWV83XXD'
WITH UR ;
---------+---------+---------+---------+---------+---------+--NAME
CREATOR
CREATEDBY
---------+---------+---------+---------+---------+---------+--WWV83XXD SYSPROG
SYSPROG
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---

SYSPROG is the owner of the database WWV83XXD.

---------+---------+---------+---------+---------+---------+---------+---------+---SELECT SUBSTR(GRANTOR,1,8) AS GRANTOR,


SUBSTR(GRANTEE,1,8) AS GRANTEE,
SUBSTR(NAME,1,8) AS NAME,
AUTHHOWGOT,CREATETABAUTH,CREATETSAUTH,DISPLAYDBAUTH
FROM SYSIBM.SYSDBAUTH
WHERE GRANTEE = 'WWCV83ST'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+---------+---GRANTOR
GRANTEE
NAME
AUTHHOWGOT CREATETABAUTH CREATETSAUTH DISPLAYDBAUTH
---------+---------+---------+---------+---------+---------+---------+---------+---SYSPROG
WWCV83ST WWV83XXD S
Y
Y
Y
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+----

The Secondary Authid WWCV83ST has the privileges to create table spaces, tables and
display the status of the database WWV83XXD. SYSPROG who has SYSADM authority
granted the Secondary Authorization id WWV83ST these privileges.

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
SELECT SUBSTR(GRANTOR,1,8) AS GRANTOR,
SUBSTR(GRANTEE,1,8) AS GRANTEE,
SUBSTR(NAME,1,8) AS NAME,
AUTHHOWGOT,CREATETABAUTH,CREATETSAUTH,DBADMAUTH
FROM SYSIBM.SYSDBAUTH
WHERE NAME
= 'WWV83XXD'
AND GRANTEE = 'SYSPROG'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+---------+
GRANTOR
GRANTEE
NAME
AUTHHOWGOT CREATETABAUTH CREATETSAUTH DBADMAUTH
---------+---------+---------+---------+---------+---------+---------+---------+
SYSPROG
SYSPROG
WWV83XXD S
G
G
G

DSNE610I NUMBER OF ROWS DISPLAYED IS 1


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+
Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-155

Student Exercises

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

The database owner SYSPROG has all these privileges with GRANT option.

A-156 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Privileges required to create a table (for example, with different owner)

Steps 10 to 11: Current SQLID = USER, unqualified table name:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
SET CURRENT SQLID = USER;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
CREATE TABLE T1
(COL1 CHAR(1))
IN DATABASE WWV83XXD
---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -551, ERROR: TSOUB01 DOES NOT HAVE THE PRIVILEGE TO PERFORM
OPERATION CREATE TABLE ON OBJECT WWV83XXD
DSNT418I SQLSTATE
= 42501 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXODD2 SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= 50 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'00000032' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

This is because the privileges on database WWCV83XXD have been granted to your
Secondary Authorization id and not to your Primary Authid.

Steps 12 to 13: Current SQLID = RACF group, unqualified table name:

cl

---------+---------+---------+---------+---------+---------+---------+---------+
SET CURRENT SQLID = 'WWCV83ST';
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Ex

CREATE TABLE T01A


(COL1 CHAR(1))
IN DATABASE WWV83XXD
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

pr

The CREATE is successful because WWCV83ST has the authority to create the table
(CREATETAB, and for the implicit tablespace creation: USE OF STOGROUP and
USE OF BUFFERPOOL).

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-157

Student Exercises

Steps 14 to 15: Current SQLID = USER, qualified table name:


---------+---------+---------+---------+---------+---------+---------+---------+
SET CURRENT SQLID = USER;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

CREATE TABLE WWCV83ST.T01B


(COL1 CHAR(1))
IN DATABASE WWV83XXD
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

The CREATE is successful because WWCV83ST has the authority to create the table
(CREATETAB, and for the implicit tablespace creation: USE OF STOGROUP and
USE OF BUFFERPOOL).

Steps 16 to 17: Current SQLID = RACF group, qualified table name:


---------+---------+---------+---------+---------+---------+---------+---------+
SET CURRENT SQLID = 'WWCV83ST';
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

Ex

cl

CREATE TABLE TSOUB01.T2


(COL1 CHAR(1))
IN DATABASE WWV83XXD
---------+---------+---------+---------+---------+---------+---------+---------+
DSNT408I SQLCODE = -551, ERROR: TSOUB01 DOES NOT HAVE THE PRIVILEGE TO PERFORM
OPERATION CREATE TABLE ON OBJECT WWV83XXD
DSNT418I SQLSTATE
= 42501 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXODD2 SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= 50 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION
DSNT416I SQLERRD
= X'00000032' X'00000000' X'00000000' X'FFFFFFFF'
X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+

pr

This is because the privileges on database WWCV83XXD have been granted to your
Secondary Authorization id and not to your Primary Authid. In this case although
WWCV83ST has the privilege to create a table in database WWV83XXD, the table owner
has to be your Primary Authid and this is not possible.

A-158 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Privileges needed for DML

Step 18: Current SQLID = USER, selecting from one groups table

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
SET CURRENT SQLID = USER;
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
SELECT *
FROM WWCV83ST.T01A
---------+---------+---------+---------+---------+---------+---------+---------+
COL1
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE610I NUMBER OF ROWS DISPLAYED IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

Step 19: Why is the SELECT successful, even though your Primary
Authid does not have SELECT privilege on table sauthid.T??A?

The SELECT is successful because the privilege set is the set of privileges held by all
authorization ids associated with the process.

Step 20: Determining owner and schema of tables

pr

Ex

cl

---------+---------+---------+---------+---------+---------+
SELECT SUBSTR(NAME,1,8) AS NAME,
SUBSTR(CREATOR,1,8) AS CREATOR,
SUBSTR(DBNAME,1,8) AS DBNAME,
SUBSTR(TSNAME,1,8) AS TSNAME,
SUBSTR(CREATEDBY,1,8) AS CREATEDBY,
SUBSTR(OWNER,1,8) AS OWNER
FROM SYSIBM.SYSTABLES
WHERE NAME IN ('T01A', 'T01B')
AND DBNAME = 'WWV83XXD'
WITH UR ;
---------+---------+---------+---------+---------+---------+-NAME
CREATOR
DBNAME
TSNAME
CREATEDBY
OWNER
---------+---------+---------+---------+---------+---------+-T01A
WWCV83ST WWV83XXD T01A
TSOUB01
WWCV83ST
T01B
WWCV83ST WWV83XXD T01B
TSOUB01
WWCV83ST
DSNE610I NUMBER OF ROWS DISPLAYED IS 2
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+--

Note: CREATOR shows schema name and OWNER shows the owner of the table.
Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-159

Student Exercises

Step 21: Which of your auth ids is allowed to query SYSTABLES?

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+
SELECT SUBSTR(GRANTOR,1,8) AS GRANTOR,
SUBSTR(GRANTEE,1,8) AS GRANTEE,
SUBSTR(TCREATOR,1,8) AS TCREATOR,
SUBSTR(TTNAME,1,10) AS TTNAME,
AUTHHOWGOT,SELECTAUTH
FROM SYSIBM.SYSTABAUTH
WHERE GRANTEE IN ('TSOUB01', 'WWCV83ST')
AND TTNAME = 'SYSTABLES'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+
GRANTOR
GRANTEE
TCREATOR TTNAME
AUTHHOWGOT SELECTAUTH
---------+---------+---------+---------+---------+---------+---------+
INSCV83
TSOUB01
SYSIBM
SYSTABLES
S
Y
INSCV83
WWCV83ST SYSIBM
SYSTABLES
S
Y

pr

Ex

cl

DSNE610I NUMBER OF ROWS DISPLAYED IS 1


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+

A-160 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Exercise 10: Locking


Step 1a: Retrieving locking information from the DB2 catalog

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT SUBSTR(DBNAME,1,8) AS DBNAME,


SUBSTR(NAME,1,8) AS NAME,
SUBSTR(CREATOR,1,8) AS CREATOR,TYPE,LOCKRULE
FROM SYSIBM.SYSTABLESPACE
WHERE CREATOR = USER
WITH UR ;

---------+---------+---------+---------+---------+---------+---------+---------+
DBNAME
NAME
CREATOR
TYPE LOCKRULE
---------+---------+---------+---------+-------WWV8301D TSLOCN
TSOUB01
A
A
WWV8301D TSDEPT
TSOUB01
G
A
WWV8301D TSEMPL
TSOUB01
R
WWV8301D TSPROJ
TSOUB01
A
WWV8301D TSEXCEPT TSOUB01
A
DSNE610I NUMBER OF ROWS DISPLAYED IS 5
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

Step 1b. Retrieving RELEASE value for packages:

pr

Ex

cl

---------+---------+---------+---------+---------+---------+---------+---------+
SELECT SUBSTR(NAME,1,8)
AS NAME
, SUBSTR(CREATOR,1,8) AS CREATOR
, SUBSTR(OWNER,1,8) AS OWNER
, RELEASE
FROM SYSIBM.SYSPACKAGE
WHERE RELEASE
= 'D'
WITH UR ;
---------+---------+---------+---------+---------+---------+
NAME
CREATOR
OWNER
RELEASE
---------+---------+---------+---------+---------+---------+
DSNE610I NUMBER OF ROWS DISPLAYED IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-161

Student Exercises

Step 1c. Retrieving ISOLATION RR for packages:

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
SELECT SUBSTR(NAME,1,8) AS NAME,
SUBSTR(CREATOR,1,8) AS CREATOR,
SUBSTR(OWNER,1,8) AS OWNER
FROM SYSIBM.SYSPACKAGE
WHERE ISOLATION = 'R'
WITH UR ;
---------+---------+---------+---------+---------+---------+
NAME
CREATOR
OWNER
---------+---------+---------+---------+---------+---------+
DSNREXX
SYSPROG
SYSPROG
DSNESM68 SYSPROG
SYSPROG
DSNA6DB2 SYSPROG
SYSPROG
DSNA6THP SYSPROG
SYSPROG
DSNAEXPL SYSPROG
SYSPROG
DSNAHVPM SYSPROG
SYSPROG
DSNE610I NUMBER OF ROWS DISPLAYED IS 6
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

Step 2: Diagnosing an unsuccessful lock request

Ex

cl

SELECT * FROM WWCV831.DEPARTMENT


---------+---------+---------+---------+---------+---------+---------+--------DEPTNO SUPERIOR_DEPTNO MGRNO
NAME
---------+---------+---------+---------+---------+---------+---------+--------A00
--------------- 000010 SPIFFY COMPUTER SERVICE DIV.
B01
A00
000020 PLANNING
C01
A00
000030 INFORMATION CENTER
D01
A00
------ DEVELOPMENT CENTER
DSNE610I NUMBER OF ROWS DISPLAYED IS 4
DSNT408I SQLCODE = -911, ERROR: THE CURRENT UNIT OF WORK HAS BEEN ROLLED BACK
DUE TO DEADLOCK OR TIMEOUT. REASON 00C9008E, TYPE OF RESOURCE
00000304, AND RESOURCE NAME WWV83YYD.TSDEPT .X'000002' '.X'05'
DSNT418I SQLSTATE
= 40001 SQLSTATE RETURN CODE
DSNT415I SQLERRP
= DSNXRRC SQL PROCEDURE DETECTING ERROR
DSNT416I SQLERRD
= -190 -100 0 -1 -404549622 536870912 SQL DIAGNOSTIC
INFORMATION
DSNT416I SQLERRD
= X'FFFFFF42' X'FFFFFF9C' X'00000000' X'FFFFFFFF'
X'E7E3100A' X'20000000' SQL DIAGNOSTIC INFORMATION
---------+---------+---------+---------+---------+---------+---------+-DSNE618I ROLLBACK PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

pr

Reason code 00C9008E means that a lock request for the resource identified by NAME
could not be granted, and the request waited for a period longer than the maximum
specified by the installation.

TYPE OF RESOURCE 00000304 refers to a RESOURCE NAME with a format of


DB.SP.RID, where DB is the database name, SP is the space name, and RID is the record
identifier.

A-162 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Displaying locking information for a segmented table space


Step 3: Getting information about DEPARTMENT table

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+
SELECT SUBSTR(CREATOR,1,8) AS CREATOR, SUBSTR(NAME,1,10) AS NAME,
SUBSTR(DBNAME,1,8) AS DBNAME, SUBSTR(TSNAME,1,8) AS TSNAME,
DBID, OBID
FROM SYSIBM.SYSTABLES
WHERE CREATOR = 'WWCV831'
AND NAME = 'DEPARTMENT'
WITH UR ;
---------+---------+---------+---------+---------+---------+---------+
CREATOR
NAME
DBNAME
TSNAME
DBID
OBID
---------+---------+---------+---------+---------+---------+---------+
WWCV831
DEPARTMENT WWV83YYD TSDEPT
280
3
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+

Background information for the following DISPLAY outputs: Userid INSCV83 has
previously issued (without commit):

pr

Ex

cl

---------+---------+---------+---------+---------+---------+
UPDATE WWCV831.DEPARTMENT
SET NAME = '*** THIS UPDATE IS UNCOMMITTED ***'
WHERE DEPTNO = 'E01';
---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+
DSNE614I AUTOCOMMIT IS NO; NO CHANGES COMMITTED
---------+---------+---------+---------+---------+---------+

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-163

Student Exercises

Step 4: DISPLAY DB ... LOCKS


-DIS DB(WWV83YYD) SPACE(TSDEPT) LOCKS

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

DSNT360I -DSNB ***********************************


DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL LOCKS
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV83YYD STATUS = RW
DBD LENGTH = 4028
DSNT397I -DSNB
NAME
TYPE PART STATUS
CONNID
CORRID
LOCKINFO
-------- ---- ----- ----------------- -------- ------------ --------TSDEPT
TS
RW
TSO
INSCV83
H-IX,S,C
AGENT TOKEN 301
TSDEPT
TS
RW
TSO
TSOUB01
H-IS,S,C
AGENT TOKEN 315
TSDEPT
TS
RW
TSO
TSOUB02
H-IS,S,C
AGENT TOKEN 316
TSDEPT
TS
RW
TSO
TSOUB03
H-IS,S,C
AGENT TOKEN 317
3
TB
TSO
INSCV83
H-IX,T,C
AGENT TOKEN 301
3
TB
TSO
TSOUB01
H-IS,T,C
AGENT TOKEN 315
3
TB
TSO
TSOUB02
H-IS,T,C
AGENT TOKEN 316
3
TB
TSO
TSOUB03
H-IS,T,C
AGENT TOKEN 317
******* DISPLAY OF DATABASE WWV83YYD ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
***

Remark: Output depends on circumstances.

Step 4a to b

cl

In the example output, TSO userid INSCV83 is holding a lock in IX mode on table space
TSDEPT and a lock in X mode on a table with an object ID of 3 (table DEPARTMENT).

Ex

Step 4c

The locks will be freed at COMMIT.

pr

Step 4d

TSO userids TSOUB01, TSOUB02 and TSOUB03 are holding lock in IS mode on the
table space WWV83YYD.TSDEPT. TSOUB01 is holding a lock in IX mode on the
DEPARTMENT table (OBID 3). TSOUB02 and TSOUB03 are holding lock in IS mode on
the DEPARTMENT table.

A-164 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

Step 4e: LOCKSIZE ROW was specified

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

SELECT SUBSTR(DBNAME,1,8) AS DBNAME,


SUBSTR(NAME,1,8) AS NAME,
SEGSIZE,LOCKRULE
FROM SYSIBM.SYSTABLESPACE
WHERE DBNAME = 'WWV83YYD'
AND NAME = 'TSDEPT'
WITH UR ;
---------+---------+---------+---------+---------+---------+
DBNAME
NAME
SEGSIZE LOCKRULE
---------+---------+---------+---------+---------+---------+
WWV83YYD TSDEPT
4 R

Step 5 (optional): Locking information for a partitioned table space


Prolog: Your instructor id INSCV83 has previously issued (without commit):

---------+---------+---------+---------+---------+---------+---------+---------+
UPDATE EMPLOYEE
SET SALARY = SALARY * 1.1
WHERE EMPNO = '000200'
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE614I AUTOCOMMIT IS NO; NO CHANGES COMMITTED
---------+---------+---------+---------+---------+---------+---------+---------+

-DISPLAY DATABASE (WWV83YYD) LOCKS

pr

Ex

cl

DSNT360I -DSNB ***********************************


DSNT361I -DSNB * DISPLAY DATABASE SUMMARY
*
GLOBAL LOCKS
DSNT360I -DSNB ***********************************
DSNT362I -DSNB
DATABASE = WWV83YYD STATUS = RW
DBD LENGTH = 4028
DSNT397I -DSNB
NAME
TYPE PART STATUS
CONNID
CORRID
LOCKINFO
-------- ---- ----- ----------------- -------- ------------ --------TSDEPT
TS
RW
TSO
INSCV83
H-IX,S,C
AGENT TOKEN 365
3
TB
TSO
INSCV83
H-X,T,C
AGENT TOKEN 365
TSEMPL
TS
0001 RW
TSEMPL
TS
0002 RW
TSO
INSCV83
H-IX,P,C
AGENT TOKEN 365
TSEMPL
TS
0003 RW
TSEMPL
TS
RW
******* DISPLAY OF DATABASE WWV83YYD ENDED
**********************
DSN9022I -DSNB DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION
***

Note: The current update changes one page in one partition - and only this partition gets
an IX lock.

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-165

Student Exercises

Step 6: Reading uncommitted data


SELECT *
FROM WWCV831.DEPARTMENT
WITH UR

A00
B01
C01
D01
E01
D11
D21
E11
E21

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

---------+---------+---------+---------+---------+---------+---------+---------+
DEPTNO SUPERIOR_DEPTNO MGRNO
NAME
---------+---------+---------+---------+---------+---------+---------+---------+
--------------A00
A00
A00
A00
D01
D01
E01
E01

000010
000020
000030
-----000050
000060
000070
000090
000100

SPIFFY COMPUTER SERVICE DIV.


PLANNING
INFORMATION CENTER
DEVELOPMENT CENTER
*** THIS UPDATE IS UNCOMMITTED ***
MANUFACTURING SYSTEMS
ADMINISTRATION SYSTEMS
OPERATIONS
SOFTWARE SUPPORT

DSNE610I NUMBER OF ROWS DISPLAYED IS 9


DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+

Step 7: Reason why UR is successful

A SELECT statement that specifies UR ignores any locks and does not acquire any locks
on the data being accessed, and therefore the SELECT is successful.
Remark: When you remove the UR option, you find that the SELECT times out again
because the table is still locked in X mode by another user.

Step 8: SKIP LOCKED DATA

pr

Ex

cl

SELECT * FROM WWCV831.DEPARTMENT SKIP LOCKED DATA


---------+---------+---------+---------+---------+---------+DEPTNO SUPERIOR_DEPTNO MGRNO
NAME
---------+---------+---------+---------+---------+---------+A00
--------------- 000010 SPIFFY COMPUTER SERVICE DIV.
B01
A00
000020 PLANNING
C01
A00
000030 INFORMATION CENTER
D01
A00
------ DEVELOPMENT CENTER
D11
D01
000060 MANUFACTURING SYSTEMS
D21
D01
000070 ADMINISTRATION SYSTEMS
E11
E01
000090 OPERATIONS
E21
E01
000100 SOFTWARE SUPPORT
DSNE610I NUMBER OF ROWS DISPLAYED IS 8
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+DSNE617I COMMIT PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

A-166 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

V5.4.0.3
Student Exercises

EXempty

SKIP LOCKED DATA skips the row for DEPTNO E01 as this row is locked. UR retrieves
the row for DEPTNO E01 although this row is not committed. You see only committed
rows with SKIP LOCKED DATA.

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

End of exercise

Copyright IBM Corp. 1993, 2011

Appendix A. Exercise solutions

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

A-167

pr

Ex

cl

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

Student Exercises

A-168 DB2 10 for z/OS DB Admin Workshop Part 1

Copyright IBM Corp. 1993, 2011

Course materials may not be reproduced in whole or in part


without the prior written permission of IBM.

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

backpg

pr

cl

Ex
V5.4.0.3

Back page

pr

u
oy si
ec vo
to fo
C rm
.F a
.T ci
.I. n
C
.

cl

Ex

CONTACTO
Telfono
91 761 21 78
Pngase en contacto con nuestro equipo y le
informaremos de cualquier duda o cuestin
que pueda surgirle.

Email
formacion@arrowecs.es
Mndenos un email y le atenderemos
enseguida.

Online
@Arrow_Edu_ES
O bien puede contactarnos a travs de
nuestro perfil en Twitter.

Vistenos
Arrow ECS Education Services
Avenida de Europa 21,
Parque Empresarial La Moraleja
28108 Alcobendas, Madrid

EDUCATION
S

S-ar putea să vă placă și