DB2 Online

138
06/06/22 DB2/OS390 DB2/OS390 Database Class Database Class EXIT >

Transcript of DB2 Online

Page 1: DB2 Online

04/09/23

DB2/OS390 DB2/OS390 Database Class Database Class

EXITEXIT>>

Page 2: DB2 Online

04/09/23

DB2DB2 Version 5.1 Version 5.1

EXITEXITMAIN MENUMAIN MENU>><<

Page 3: DB2 Online

04/09/23

DB2 CLASS DB2 CLASS OUTLINEOUTLINE MAIN MENU MAIN MENU

Relational DatabaseRelational DatabaseBrief Discussion of Relational Database -

Physical StructuresPhysical StructuresDB2 Physical Structures -

DDLDDL

DCLDCL

DMLDML

DB2 InternalsDB2 Internals

Commands/UtilitiesCommands/Utilities

DDL - Data Definition Language -

DCL - Data Control Language -

DML - Data Manipulation Language -

DB2 Internal Functions -

DB2 Commands & Utilities -

>><< EXITEXIT

Appendixes - AppendixesAppendixes

Page 4: DB2 Online

04/09/23

RELATIONAL RELATIONAL DATABASEDATABASE Basic Elements Basic Elements

EXITEXITMAIN MENUMAIN MENU>><<

DB2 (MVS) Version 1 introduced in 1983. Built on Dr. Codd's Relational Database Model.

First Basic Element: Table

In which columns represent things and the attributes that describe them; and rows that represent specific instances or occurrences of the thing described.

Second Basic Element: Operators (SQL Language)

Structured procedure for defining, controlling, manipulating, and retrieving information from a database (i.e. table).

Note - SQL (Structured Query Language) consists of: DDL (Data Definition Language), DCL (Data Control Language), and DML (Data Manipulation Language.

Page 5: DB2 Online

04/09/23

DB2 KEY DB2 KEY COMPONENTSCOMPONENTS

EXITEXITMAIN MENUMAIN MENU>><<

MVS Subsystem Environments:

TSO - contains a teleprocessing monitor; programs may be online or batch and may not access IMS databases.

IMS - contains a teleprocessing monitor (IMS/DC or IMS/TM) and may access DB2 and IMS databases either online or batch.

CICS - contains a teleprocessing monitor and may access DB2 and IMS databases online only.

Page 6: DB2 Online

04/09/23

DB2 KEY DB2 KEY COMPONENTSCOMPONENTS

EXITEXITMAIN MENUMAIN MENU>><<

Primary Online Facilities:

QMF - Query Management Facility uses the Call Attach Facility to attach to DB2. Used to enter dynamic SQL against DB2 objects.

DB2I - DB2 Interactive is attached through TSO and is also used to enter dynamic SQL against DB2 objects. Also contains additional control features for DB2 commands and utilities.

Page 7: DB2 Online

04/09/23

DB2 PHYSICAL DB2 PHYSICAL STRUCTURESSTRUCTURES

EXITEXITMAIN MENUMAIN MENU>><<

Page 8: DB2 Online

04/09/23

DB2 Object DB2 Object HierarchyHierarchy

EXITEXITPhysical StructuresPhysical Structures>><<

Page 9: DB2 Online

04/09/23

DB2 Object DB2 Object TerminologyTerminology

Database -Database - Related Tables and Indexes and their spaces, grouped to Related Tables and Indexes and their spaces, grouped to facilitate handling.facilitate handling.

TablespaceTablespace - - An area of External Storage assigned to hold a table.An area of External Storage assigned to hold a table.

Table -Table - Actual Rows and Columns of Data.Actual Rows and Columns of Data.

Index -Index - Consists of one or more VSAM datasets used to achieve more Consists of one or more VSAM datasets used to achieve more efficient access to data pages and/or to ensure row uniqueness.efficient access to data pages and/or to ensure row uniqueness.

Synonym -Synonym - An alternate, private name for a table or view.An alternate, private name for a table or view.

View -View - A logical, column-filtered, representation of a table.A logical, column-filtered, representation of a table.

Alias -Alias - A type of global synonym for a table.A type of global synonym for a table.

EXITEXIT>><< Physical StructuresPhysical Structures

Page 10: DB2 Online

04/09/23

DB2 Table/Tablespace DB2 Table/Tablespace

Relationship Relationship

A A PagePage is the unit of transmission. is the unit of transmission. A A RowRow mustmust be contained within a single page. be contained within a single page. A A PagePage may contain several rows. may contain several rows. PagePage size is 4096 bytes. size is 4096 bytes. TablespaceTablespace, , TableTable, , PagePage, and , and RowRow are units of locking. are units of locking. Maximum Maximum TablespaceTablespace size is 1016 Gigabytes. size is 1016 Gigabytes. A A Segmented TablespaceSegmented Tablespace contains equal-sized segments of from 4 to 64 pages contains equal-sized segments of from 4 to 64 pages

in multiples of 4 pages.in multiples of 4 pages. All pages in a segment contain rows of All pages in a segment contain rows of only oneonly one table. table. A A Non-Partitioned TablespaceNon-Partitioned Tablespace (simple or segmented) can contain one or (simple or segmented) can contain one or

more tables.more tables. A A Partitioned TablespacePartitioned Tablespace can contain can contain only oneonly one table and cannot be table and cannot be

segmented.segmented.

EXITEXIT>><< Physical StructuresPhysical Structures

Page 11: DB2 Online

04/09/23

SIMPLE SIMPLE TablespaceTablespace

EXITEXIT>><<

Multiple tables can be assigned to a single simple (non-partitioned unsegmented) tablespace.

- Intermix rows of highly related tables for performance

- Rows are interleaved in the tablespace in the sequence that they are inserted/loaded.

Data Page

Physical StructuresPhysical Structures

Page 12: DB2 Online

04/09/23

PARTITIONED PARTITIONED TablespaceTablespace

EXITEXIT>><<

n = 2 - 64 Partitions.Must have a Clustering Index.Each partition (tablespace and indexspace) is a separate dataset.Partition Independence - Utilities can be run by partition.

PART n Values (5059999999)

PART 1 Values (3039999999)PARTITION 1

PARTITION n

303221000130322100023032210005

505342000150534200035053420004

Physical StructuresPhysical Structures

Page 13: DB2 Online

04/09/23

SEGMENTED SEGMENTED TablespaceTablespace

EXITEXIT>><<

Minimize datsets and associated management.Minimize data unavailability (lock contention).Minimize mass update/delete/insert time.Minimize table scan time.Clustering index clusters rows by table.

Segment 1 Segment 2

Table A Rows Table B Rows

Physical StructuresPhysical Structures

Page 14: DB2 Online

04/09/23

Tablespace Tablespace FormatFormat SEGMENTED SEGMENTED

EXITEXIT>><<

Header Page

Space Map Page

Data Page 1

Data Page n

Space Map Page

Data Page n+1

Physical StructuresPhysical Structures

Page 15: DB2 Online

04/09/23

DB2 Data DB2 Data PagePage

EXITEXIT>><<

20 BytesPage Header

RID

(Row ID)

ID Map: 2 Bytes/Row

RID

Row Data

RowHeader6 Bytes

RowHeader6 Bytes

Row Data

Physical StructuresPhysical Structures

Page 16: DB2 Online

04/09/23 EXITEXIT>><<

SEGMENTED SEGMENTED TABLESPACETABLESPACE Space Map Page Space Map Page

For 4K Pages, a Space Map controls 1712 pages for SegmentSize of 4 ... up to 5504 pages for Segment Size of 64.

MODIFIED PAGE INDICATORS (One Bit Per Page)

1 Byte Trailer

SPACE MAP OF SEGMENT ENTRIES:

One per segment (SEGBLK)

7 bytes of control information plus 4 bits per page in segment free space in page.

Page Header26 Bytes

Physical StructuresPhysical Structures

Page 17: DB2 Online

04/09/23

SEGMENTEDSEGMENTED Indexspace Indexspace FormatFormat

EXITEXIT>><<

1 Space Map Page per 32,632 Pages

Header Page

Space Map Page

Index Page 1

Index Page n

Space Map Page

Index Page n+1

Physical StructuresPhysical Structures

Page 18: DB2 Online

04/09/23

DB2 Index Leaf DB2 Index Leaf PagePage

EXITEXIT>><<

1 Byte Trailer

Free Space

Physical Header28 Bytes

Subpage Directory(4 bytes + keylength)

Logical Header17 Bytes

RID

Key RID Key RID

KeyIndexed Column(s)

Page # - 4 bytesID # - 1 byte

Max. 254 Bytes 5 Bytes

Physical StructuresPhysical Structures

Page 19: DB2 Online

04/09/23

DB2 Index DB2 Index StructureStructure

EXITEXIT>><<

DATA PAGES

Balanced Tree

ROOTPAGE

NONLEAFPAGE

NONLEAFPAGE

LEAFPAGE

LEAFPAGE

LEAFPAGE

Physical StructuresPhysical Structures

Page 20: DB2 Online

04/09/23

DB2 Index DB2 Index TerminologyTerminology

Clustering -Clustering - Maintaining the order of data pages to match the Maintaining the order of data pages to match the index.index.

Unique - Unique - Only oneOnly one value for that column or columns. value for that column or columns.

Non-Unique - Non-Unique - Duplicates allowed.Duplicates allowed.

Partitioned - Partitioned - The partition is determined by a The partition is determined by a rangerange ofof valuesvalues for for this type of index.this type of index.

Non-Partitioned - Non-Partitioned - Not dependent on any partition; includes the Not dependent on any partition; includes the entire table.entire table.

Primary Key - Primary Key - Indicates Indicates Referential IntegrityReferential Integrity; i.e. Parent Table.; i.e. Parent Table.

Foreign Key - Foreign Key - Indicates Indicates Referential IntegrityReferential Integrity; i.e. Dependent (or ; i.e. Dependent (or Child) Table.Child) Table.

EXITEXIT<< Physical StructuresPhysical Structures

Page 21: DB2 Online

04/09/23

DDL (Data Definition DDL (Data Definition Language)Language)

EXITEXITMAIN MENUMAIN MENU

CREATE - CREATE - Database, Tablespace, Table, Database, Tablespace, Table, Index, Index, Synonym, View, Alias, Synonym, View, Alias, StogroupStogroup

ALTER - ALTER - Tablespace, Table, Index, Stogroup Tablespace, Table, Index, Stogroup

DROP - DROP - Database, Tablespace, Table, Index, Database, Tablespace, Table, Index, Synonym, View, Alias, Stogroup Synonym, View, Alias, Stogroup

CREATE DDLCREATE DDL

ALTER DDLALTER DDL

DROP DDLDROP DDL

Page 22: DB2 Online

04/09/23

CREATE CREATE DATABASEDATABASE

EXITEXITDDLDDL>>

A DATABASE is related tables and indexes andtheir spaces grouped to facilitate handling.

CREATE DATABASE CRISAPDB

STOGROUP CRISGRP1 BUFFERPOOL BP0

Note: No ALTER DATABASE

Page 23: DB2 Online

04/09/23

CREATE CREATE TABLESPACETABLESPACE

EXITEXIT>><<

A TABLESPACE is an area of external storageassigned to hold a table.

CREATE TABLESPACE CRISAPTS IN CRISAPDB

USING STOGROUP CRISGRP1 PRIQTY 180000 (in Kbytes) SECQTY 3600 (in Kbytes) ERASE NO (binary 0 overwrite) LOCKSIZE ANY (also Page or Tablespace) BUFFERPOOL BP0 (60 available buffers) CLOSE NO FREEPAGE 63 (after every 63, 1 empty) PCTFREE 10 (free space on each page) SEGSIZE 64

DDLDDL

Page 24: DB2 Online

04/09/23

3390 EQUIVALENT 3390 EQUIVALENT DASDDASD

EXITEXIT>><<

12 - DB2 4K Pages per Track15 - Tracks per Cylinder256 - VSAM Extents per Dataset (Version 5.1)

File-AID/SPF - Utility VTOC list for DD3I61 (3390) -------- 10 DATASETS LISTED COMMAND ===> SCROLL ===> CSR VTOC: 209 Tracks ( 1 %Used) 10432 Free DSCB'S 10 Data sets VOL: 50085 Tracks ( 35 %Used) 15 Tracks/cylinder 15 ALT Tracks FREE: 2165 Cyls (MAX= 2163) 32494 Trks (MAX= 32445) 4 Free Xtnts --------- D A T A S E T N A M E ---------- Org Trks %Used XTS= Status DRM.DSNDBD.XYPRV00D.XYPRVPSS.I0001.A001 VS 30 ? 1 DRM.DSNDBD.XYPRV00D.XYPRVPS0.I0001.A001 VS 3 ? 2 DRM.DSNDBD.XYPRV00W.XYPRVPSS.I0001.A001 VS 6 ? 5 DRM.DSNDBD.XYPRV00W.XYPRVPS0.I0001.A001 VS 2 ? 1 DRMCRB0D.DSNDBD.MTRCB00D.MTRCBSIS.I0001.A001 VS 12000 ? 1 DRMSVO0D.DSNDBD.MX5AD00D.MX5AD020.I0001.A001 VS 2220 ? 12 DRMSVO0D.DSNDBD.MX5BF00D.MX5BF010.I0001.A001 VS 675 ? 37 DRMSVO0D.DSNDBD.MY5SO00D.MY5SOBRS.I0001.A001 VS 2400 ? 8 SYS1.VTOCIX.DD3I61 PS 15 100 1 SYS1.VVDS.VDD3I61 VS 30 ? 1 ******************************* Bottom of data ********************************

FA;3.7

DDLDDL

Page 25: DB2 Online

04/09/23

CREATE CREATE TABLETABLE

EXITEXIT>><<

CREATE TABLE CORPD000.CRISAPTT

(CUST_ACCT_ID CHAR(24) NOT NULL, UNIV_SRV_ORD_CD CHAR(5) NOT NULL, PROD_INTRNL_SER_ID CHAR(10) NOT NULL, . . . PROD_DISC_DAT DATE NOT NULL)

(optional referential constraints)

IN CRISAPDB.CRISAPTS

DDLDDL

Page 26: DB2 Online

04/09/23

DB2 TABLE DB2 TABLE (Example)(Example)

EXITEXIT>><< DDLDDL

CORPD000.CRISAPTT

CUST_ACCT_ID UNIV_SRV_ORD_CD PROD_INTRNL_SER_ID PROD_DISC_DAT

J5202810165841 WAXSQ 5201400470 2099-12-31J5202810197677 WAXSQ 5201408956 2099-12-31J5202810197677 WAXSQ 5201408957 2099-12-31J5202810197677 WAXSQ 5201408958 2099-12-31J5202810197677 WAXSQ 5201408959 2099-12-31J5202810420627 CPERN 5202810420 2099-12-31J5202810420627 WAXSQ 5201408916 2099-12-31J5202810572948 WAXSQ 5201408840 2099-12-31J5202810585640 WAXSQ 5201408808 2099-12-31J5202810585640 WAXSQ 5201408809 2099-12-31J5202810602687 PYKMN 5202810602 2099-12-31

Page 27: DB2 Online

04/09/23

CREATE CREATE INDEXINDEX

EXITEXIT>><<

CREATE UNIQUE INDEX CORPD000.CRISAPT1 ON CORPD000.CRISAPTT

(CUST_ACCT_ID ASC, (default Ascending) PROD_DISC_DAT DESC) (Descending)

USING STOGROUP CRISGRP2 PRIQTY 54000 (in Kbytes) SECQTY 9000 (in Kbytes) ERASE NO BUFFERPOOL BP2 (Assigned Bufferpool) CLOSE NO FREEPAGE 31 (after 31 pages, 1 empty) PCTFREE 20 (freespace on the index page) CLUSTER (only one per table)Note: Duplicate values are not allowed for this index key.

DDLDDL

Page 28: DB2 Online

04/09/23

PARTITIONINGPARTITIONING

EXITEXIT>><<

1. CREATE TABLESPACE CRSPARTS IN CRSPRTDB

NUMPARTS 4 (no. of partitions) USING STOGROUP CRISGRP3 PRIQTY 9000 (in Kbytes) SECQTY 900 (in Kbytes) BUFFERPOOL BP0 (Assigned Bufferpool) CLOSE NO FREEPAGE 15 (after 15 pages, 1 empty) PCTFREE 10 (freespace on the data page)

2. CREATE TABLE CORPD000.CRSPARTT ... IN CRSPRTDB.CRSPARTS

DDLDDL

Page 29: DB2 Online

04/09/23

PARTITIONINGPARTITIONING

EXITEXIT>><<

3. CREATE INDEX CORPD000.CRSPARTI ON CORPD000.CRSPARTS

USING STOGROUP CRISGRP4 PRIQTY 360 SECQTY 180 CLUSTER (PART 1 VALUES(wwwwwww), PART 2 VALUES(xxxxxxxxxx), PART 3 VALUES(yyyyyyyyyy), PART 4 VALUES(zzzzzzzzzzz)) CLOSE NO BUFFERPOOL BP9

DDLDDL

Page 30: DB2 Online

04/09/23

CREATE VIEWCREATE VIEW

EXITEXIT>><<

A VIEW is a logical, column-filtered, representation of a table.

CREATE VIEW CRISAPTV

(CUST_ACCT_ID, UNIV_SRV_ORD_CD)

AS

SELECT CUST_ACCT_ID, UNIV_SRV_ORD_CD FROM CORPD000.CRISAPTT

Note: No ALTER for VIEW.

Also: A View cannot contain an ORDER BY, UNION, FOR UPDATE OF.

DDLDDL

Page 31: DB2 Online

04/09/23

CREATE CREATE SYNONYMSYNONYM

EXITEXIT>><<

A SYNONYM is an alternate name for a table or view and can be accessed only by their creator.

CREATE SYNONYM CRISSYNY

FOR CORPD000.CRISAPTT

Note: No ALTER for SYNONYM

DDLDDL

Page 32: DB2 Online

04/09/23

CREATE ALIASCREATE ALIAS

EXITEXIT<<

An ALIAS is a locally defined name for a table or view in the same local DB2 subsystem or in a remote DB2 Subsystem. Aliases can be accessed by users other than their creator.

CREATE ALIAS CRISAPTA

FOR DBJM.CORPD000.CRISAPTT

Note: No ALTER for ALIAS

DDLDDL

Page 33: DB2 Online

04/09/23

ALTER ALTER TABLESPACETABLESPACE

EXITEXIT>>

ALTER TABLESPACE CRISAPTS

USING STOGROUP CRISGRP1 PRIQTY 180000 (in Kbytes) SECQTY 3600 (in Kbytes) ERASE NO (binary 0 overwrite) LOCKSIZE ANY (also Page or Tablespace) BUFFERPOOL BP8 (60 available buffers) CLOSE NO FREEPAGE 63 (after every 63, 1 empty) PCTFREE 15 (free space on each page) Note - SEGSIZE is not alterable.

DDLDDL

Page 34: DB2 Online

04/09/23

ALTER TABLEALTER TABLE

EXITEXIT>><<

ALTER TABLE CORPD000.CRISAPTT (add a column)

ADD PROD_DAT DATE NOT NULL WITH DEFAULT

(optional referential constraints)

Note: NOT NULL disallowed when adding column.

DDLDDL

Page 35: DB2 Online

04/09/23

ALTER ALTER INDEXINDEX

EXITEXIT<<

ALTER INDEX CORPD000.CRISAPT1

USING STOGROUP CRISGRP2 PRIQTY 54000 (in Kbytes) SECQTY 9000 (in Kbytes) ERASE NO BUFFERPOOL BP9 (Assigned Bufferpool CLOSE NO FREEPAGE 31 (after 31 pages, 1 empty) PCTFREE 10 (freespace on the index page) Note - SUBPAGES and CLUSTER not alterable.

DDLDDL

Page 36: DB2 Online

04/09/23

DROPDROP

EXITEXIT>>

The DROP statement deletes a DB2 object. Except forstorage groups and aliases, any objects that are directly or indirectly dependent on that object are also deleted. Whenever an object is deleted , its description is deleted from the catalog and any plans or packages that refer to theobject are invalidated.

DDLDDL

Page 37: DB2 Online

04/09/23

DROPDROP

EXITEXIT<<

DROP ALIAS alias-name DATABASE database-name INDEX index-name STOGROUP stogroup-name SYNONYM synonym TABLE table-name TABLESPACE database-name.tablespace-name VIEW view-name PACKAGE collection-id.package-id VERSION version-id

Note - need owner, DBADM, SYSCTRL, or SYSADM.

Remember the cascade effect of dropping objects!

DDLDDL

Page 38: DB2 Online

04/09/23

DCL (Data Control DCL (Data Control Language)Language)

GRANT - GRANT - Privileges Privileges

Revoke - Revoke - Privileges Privileges

EXITEXITMAIN MENUMAIN MENU

GRANT DCLGRANT DCL

REVOKE DCLREVOKE DCL

Page 39: DB2 Online

04/09/23

GRANTGRANT

EXITEXITDCLDCL>>

The GRANT statement allows privileges to authorization IDs. There is a separate form of the statement for each of these classes of privileges:

Collection Database Package Plan System Table/View Use

<<

Page 40: DB2 Online

04/09/23

GRANTGRANT

EXITEXIT>><<

GRANT authorization-specification

TO authorization-name PUBLIC

(WITH GRANT OPTION)

authorization-specification - Names one or more privileges in one of the formats described later.

authorization-name - One or more authorization IDs.

PUBLIC - Grants the privileges to all users

DCLDCL

Page 41: DB2 Online

04/09/23

GRANT (Collection GRANT (Collection Privileges)Privileges)

EXITEXIT>><<

GRANT CREATE IN COLLECTION collection-id PACKADM ON *

TO authorization-name PUBLIC

(WITH GRANT OPTION)

CREATE IN - Grants the BIND privilege to create packages in designated collections.

PACKADM ON - Grants package administrator authority for the designated collections.

COLLECTION collection-id - Identifies the collections on which the specified privilege is granted.

COLLECTION * - Indicates that the specified privilege is granted on all collections.

DCLDCL

Page 42: DB2 Online

04/09/23

GRANT (Database GRANT (Database Privileges)Privileges)

EXITEXIT>><<

GRANT DBADM ON DATABASE database-name DBCTRL DBMAINT CREATETAB CREATETS DISPLAYDB DROP IMAGCOPY LOAD RECOVERDB REORG REPAIR STARTDB STATS STOPDB

TO authorization-name PUBLIC (WITH GRANT OPTION)

DCLDCL

Page 43: DB2 Online

04/09/23

GRANT (Database GRANT (Database Privileges)Privileges)

EXITEXIT>><<

DBADM - Database administrator authority.DBCTRL - Database control authority.DBMAINT - Database maintenance authority.CREATETAB - Create new tables privilege.CREATETS - Create new tablespaces privilege.DISPLAYDB - Issue DISPLAY DATABASE command.DROP - DROP/ALTER DATABASE privilege.IMAGCOPY - COPY, MERGECOPY, QUIESCE, MODIFY privilege.LOAD - LOAD utility privilege.RECOVERDB - RECOVER and REPORT utility privilege.REORG - REORG utility privilege (tablespace & indexes).REPAIR - REPAIR and DIAGNOSE utility privilege.STARTDB - Issue START DATABASE command.STATS - RUNSTATS and CHECK utility privilege.STOPDB - Issue STOP DATABASE command.

DCLDCL

Page 44: DB2 Online

04/09/23

GRANT (Package GRANT (Package Privileges)Privileges)

EXITEXIT>><<

GRANT ALL ON PACKAGE/PROGRAM BIND , COPY , EXECUTE/RUN

collection-id.package-id *

TO authorization-name PUBLIC (WITH GRANT OPTION)

DCLDCL

Page 45: DB2 Online

04/09/23

GRANT (Package GRANT (Package Privileges)Privileges)

EXITEXIT>><<

BIND - Grants the BIND and REBIND privilege.

COPY - Grants the COPY option privilege of the BIND subcommand.

EXECUTE/RUN - Grants the privilege to run the program.

ALL - Grants all privileges for which you have grant authority.

collection-id.package-id - explicitly identifies a single package.

collection.* - applies to every package in the collection.

DCLDCL

Page 46: DB2 Online

04/09/23

GRANT (Plan GRANT (Plan Privileges)Privileges)

EXITEXIT>><<

GRANT BIND ON PLAN plan-name EXECUTE

TO authorization-name PUBLIC

(WITH GRANT OPTION)

BIND - Grants the BIND, REBIND and FREE privilege.

EXECUTE - Grants the privilege to run programs using this plan.

plan-name - Identifies the application plan.

DCLDCL

Page 47: DB2 Online

04/09/23

GRANT (System GRANT (System Privileges)Privileges)

EXITEXIT>><<

GRANT ARCHIVE BINDADD BINDAGENT BSDS CREATEALIAS CREATEDBA CREATEDBC CREATESG DISPLAY

TO authorization-name PUBLIC (WITH GRANT OPTION)

MONITOR1MONITOR2RECOVERSTOPALLSTOSPACESYSADMSYSCTRLSYSOPRTRACE

DCLDCL

Page 48: DB2 Online

04/09/23

GRANT (System GRANT (System Privileges)Privileges)

EXITEXIT>><<

ARCHIVE - ARCHIVE LOG command privilege.BINDADD - Create plans and packages with BIND subcommand.BINDAGENT - BIND, REBIND, FREE/DROP package privilege.BSDS - RECOVER BSDS command privilege.CREATEALIAS - CREATE ALIAS .CREATEDBA - CREATE DATABASE authority ( DBADM).CREATEDBC - CREATE DATABASE authority (DBCTRL).CREATESG - Create new strorage groups privilege.DISPLAY -DISPLAY bufferpool, database, thread, trace, location.MONITOR1 - Privilege to obtain IFC data.MONITOR2 - Privilege to obtain IFC data.RECOVER - RECOVER INDOUBT command privilege.STOPALL - STOP DB2 command privilege.STOSPACE - STOSPACE utility privilege.SYSADM - Grants all DB2 privileges.SYSCTRL - Same as SYSADM without read/update of user data.SYSOPR - System operator authority.TRACE - START, MODIFY, STOP TRACE command privilege.

DCLDCL

Page 49: DB2 Online

04/09/23

GRANT (Table/View GRANT (Table/View Privileges)Privileges)

EXITEXIT>><<

GRANT ALL ON table-name/view-name ALTER DELETE INDEX INSERT SELECT UPDATE (column-name)

TO authorization-name PUBLIC (WITH GRANT OPTION)

DCLDCL

Page 50: DB2 Online

04/09/23

GRANT (Table/View GRANT (Table/View Privileges)Privileges)

EXITEXIT>><<

ALL - All table or view privileges.

ALTER - ALTER TABLE privilege.

DELETE - DELETE statement privilege.

INDEX - CREATE INDEX privilege.

INSERT - INSERT statement privilege.

SELECT - SELECT statement privilege.

UPDATE - UPDATE statement privilege. column-name - Column specific UPDATE authority.

DCLDCL

Page 51: DB2 Online

04/09/23

GRANT (Use GRANT (Use Privileges)Privileges)

EXITEXIT>><<

GRANT USE OF

BUFFERPOOL bpname ALL BUFFERPOOLS STOGROUP sgname TABLESPACE dbname.tsname

TO authorization-name PUBLIC (WITH GRANT OPTION)

DCLDCL

Page 52: DB2 Online

04/09/23

GRANT (Use GRANT (Use Privileges)Privileges)

EXITEXIT<<

BUFFERPOOL bpname - Allows use of this buffer for CREATE/ALTER TABLESPACE/INDEX.

ALL BUFFERPOOLS - Grants the privilege to refer to any buffer pool in a CREATE/ALTER TABLESPACE/INDEX.

STOGROUP sgname - Allows use of specified storage group for CREATE/ALTER TABLESPACE/INDEX.

TABLESPACE dbname.tsname - Allows reference to the specified tablespace in CREATE TABLE.

DCLDCL

Page 53: DB2 Online

04/09/23

REVOKEREVOKE

EXITEXIT

The REVOKE statement revokes privileges from authorization IDs. There is a separate form of the statement for each of these classes ofprivileges (see GRANT syntax):

Collection Database Package Plan System Table/View Use

>> DCLDCL

Page 54: DB2 Online

04/09/23

REVOKEREVOKE

EXITEXIT

REVOKE authorization-specification

FROM authorization-name PUBLIC

BY authorization-name

authorization-specification - Names one or more privileges in one of the referred to formats.

authorization-name - One or more authorization IDs.

PUBLIC - Revokes a grant of privileges to PUBLIC.

<< DCLDCL

Page 55: DB2 Online

04/09/23

DML DML (Data Manipulation (Data Manipulation Language)Language)

EXITEXITMAIN MENUMAIN MENU>>

INSERTINSERTINSERT -

UPDATEUPDATEUPDATE -

DELETEDELETE

COMMITCOMMIT

SELECTSELECT

DELETE -

COMMIT -

SELECT -

Page 56: DB2 Online

04/09/23

INSERTINSERT

EXITEXITDMLDML>><<

The INSERT statement inserts rows into a table or view. Inserting a row into a view also inserts a row into the table on which the view is based. The view may not be a Join View.

INSERT INTO table-name ( column-name ,) view-name

VALUES(host-variable) constant/literal NULL special-register

subselect

Page 57: DB2 Online

04/09/23

INSERTINSERT

EXITEXIT>><<

INSERT (continued)

table-name - name of the table.view-name - logical name of the table.column-name - unqualified column name of table.host-variable - output variable with an assigned value.constant/literal - specifies a value( string/numeric). NULL - represents the the null value.special-register - specially defined storage area.subselect - set of rows from a result set of a subselect.

Note - need INSERT, owner, DBADM, or SYSADM Authority.

DMLDML

Page 58: DB2 Online

04/09/23

MASS MASS INSERTINSERT

EXITEXIT>><<

The mass INSERT can have a real impact on runtime performance.If the inserts are based on an ever increasing/ascending key, eachtime the index page becomes full that page is split with half of theentries staying and half moving to the new index page resulting ina large number of half-filled index pages and a lot of wasted DASD.

Prior to Version 3.1, this type of mass insert also resulted in track-at-time pre-formatting by DB2 which further increased runtimes. InVersion 4.1, this movement of half of the index entries no longeroccurs and DB2 merely starts inserting into the next index page.

DMLDML

Page 59: DB2 Online

04/09/23

MASS MASS INSERTINSERT

EXITEXIT>><<

If the inserts are more random, the deciding factors on performance become the amount of freespace on both the data pages and the index pages and synchronous (or random) I/O. If insufficient freespace exists (both percent free and freepage), the page splits that occur can make for very disorganized data. DB2 I/O Wait Time can be a large part of the overall runtime (ex. 225,000 synchronous I/O at 16 msec per I/O represents 1 hour of wait time).

Faster DASD (i.e. EMC or High-Cached Iceberg) has helped reduce the effect of large numbers of synchronous I/O. With an average I/O in the 4 - 7 msec range, the same 225,000 synchronous I/O now takes around 20 minutes instead of 60 minutes. Also, Version 3.1 contained what is called an INSERT Procedure that is part of the DB2 internal code which made mass inserting much faster.

DMLDML

Page 60: DB2 Online

04/09/23

UPDATEUPDATE

EXITEXIT>><<

The UPDATE statement updates the values of specified columnsin rows of a table or view. Updating a row of a view also updatesthat row of the table on which the view is based. The view maynot be a Join View.

UPDATE table-name view-name

SET column-name=expression , NULL

WHERE search-condition (Searched Update) WHERE CURRENT OF cursor-name (Positioned Update)

DMLDML

Page 61: DB2 Online

04/09/23

UPDATEUPDATE

EXITEXIT>><<

UPDATE (continued)

table-name - name of the table.view-name - logical name of the table.column-name - unqualified column name of table.expression - specifies a value (not a column function).NULL - represents the null value.search-condition - combination of operators and predicates. cursor-name - identifies the declared cursor.

Note - need UPDATE, owner, DBADM, or SYSADM Authority.

DMLDML

Page 62: DB2 Online

04/09/23

MASS MASS UPDATEUPDATE

EXITEXIT>><<

The mass UPDATE can have a real impact on runtime performance.If the table contains variable length rows (i.e. contains columnsdefined as VARCHAR or the table has compression turned on), whena column(s) is changed/updated, the row may not fit on the samepage which requires DB2 to find another page on which to place it.

This causes DB2 to delete the old row from the old page and insertthe row on a new page. Freespace, again plays an important partin whether the row is now situated very far from the old page whichaffects the organization of the overall table. Without suitable free-space, the cluster ratio of the data decreases rapidly and subsequentSQL may suffer performance degradation.

DMLDML

Page 63: DB2 Online

04/09/23

MASS UPDATEMASS UPDATE

EXITEXIT>><<

DO NOT UPDATE columns that are part of an index. This also causesDB2 to delete and re-insert the rows. A different way to look at it isdon't include columns in an index that may undergo frequent updating.

Version 4.1 included an UPDATE Procedure to help speed-up the massupdates. Also, in Version 4.1, UPDATEs can take advantage of DynamicPrefetch.

DMLDML

Page 64: DB2 Online

04/09/23

DELETEDELETE

EXITEXIT>><<

The DELETE statement deletes rows from a table or view. Deletinga row from a view also deletes that row from the table on which theview is based. The view may not be a Join View.

DELETE FROM table-name view-name

WHERE search-condition (Searched Delete) WHERE CURRENT OF cursor-name (Positioned Delete)

table-name - name of the table.view-name - logical name of the table.search-condition - combination of operators and predicates. cursor-name - identifies the declared cursor.

Note - need DELETE, owner, DBADM, or SYSADM Authority.

DMLDML

Page 65: DB2 Online

04/09/23

MASS MASS DELETEDELETE

EXITEXIT>><<

The mass DELETE can have a real impact on runtime performance.If the tablespace is defined as SIMPLE or PARTITIONED (which isjust a set of simple tablespaces), a mass delete (i.e. DELETE FROMTABLE-NAME with no WHERE CLAUSE - which deletes all rows)from a large table will run a long time and put quite a stress on theDB2 logs as each delete is logged.

In this case, a far better way to delete all the rows of this type oftable is to use the LOAD utility and load an empty dataset. The table is almost instantly (even magically) empty. If it is not desiredto delete all rows, then run an UNLOAD of all the rows to keep;then run a LOAD (REPLACE) with that unloaded dataset.

DMLDML

Page 66: DB2 Online

04/09/23

MASS MASS DELETEDELETE

EXITEXIT>><<

If the tablespace is defined as SEGMENTED, a mass delete is veryfast because only the SPACE MAP pages are updated to reflect allthe deleted rows. Again, if it is not desired to delete all rows (buta high percentage of the rows), use the UNLOAD/LOAD procedurepreviously outlined. In Version 4.1, DELETEs could take advantage of Dynamic Prefetch.

DMLDML

Page 67: DB2 Online

04/09/23

COMMITCOMMIT

EXITEXIT>><<

The Unit Of Recovery in which the statement is executed is endedand a new unit of recovery is started for the process. All changesmade during the unit of recovery are committed.

COMMIT WORK

JUST DO IT!

DMLDML

Page 68: DB2 Online

04/09/23

SELECTSELECT

EXITEXIT>><<

The SELECT INTO statement produces a result table containing atmost one row and assigns the values in that row to host variables.If the result table is empty, the statement assigns +100 to SQLCODEand does not assign any value to the host variables.

select-clause INTO host-variable ,

from-clause where-clause

select-clause - see appropriate layout.host-variable - compatible data type program variable.from-clause - see appropriate layout.where-clause - see appropriate layout.

Note - need SELECT, owner, DBADM, or SYSADM Authority.

DMLDML

Page 69: DB2 Online

04/09/23

select-clauseselect-clause

EXITEXIT>><<

The SELECT clause specifies the columns of the final result table.

SELECT ALL * DISTINCT expression ,

ALL - retains all rows of final result table (default).DISTINCT - eliminates duplicate rows from result table.* - indicates all columns.expression - any expression.

DMLDML

Page 70: DB2 Online

04/09/23

from-clausefrom-clause

EXITEXIT>><<

The FROM clause specifies an intermediate result table. If a singletable or view is identified, the intermediate result table is simplythat table or view. If more than one table or view is identified, theintermediate result table consists of all possible combinations ofthe rows of the identified table or views. If any table or view isempty, the result is empty.

FROM table-name , view-name

table-name - identifies an existing table.view-name - identifies an existing view.

DMLDML

Page 71: DB2 Online

04/09/23

where-clausewhere-clause

EXITEXIT>><<

The WHERE clause specifies an intermediate result table that consistsof those rows of the result table for which the search condition is true.

WHERE search-condition

search-condition predicate NOT (search-condition)

AND predicate OR NOT (search-condition)

predicate - operators (=,<,>,LIKE,BETWEEN,IN,etc.)AND/OR - logical operators

DMLDML

Page 72: DB2 Online

04/09/23

DECLARE DECLARE CURSORCURSOR

EXITEXIT>><<

The DECLARE CURSOR statement declares a cursor and can onlybe embedded in an application program.

DECLARE cursor-name CURSOR WITH HOLD FOR full-select ORDER BY FOR UPDATE OF FOR FETCH ONLY OPTIMIZE FOR

DMLDML

Page 73: DB2 Online

04/09/23

DECLARE DECLARE CURSORCURSOR

EXITEXIT>><<

DECLARE CURSOR (continued)

cursor-name - name of the cursor.WITH HOLD - cursor not closed at commit point.full-select - select-clause, from-clause, where-clause.ORDER BY - orders the rows of the result table.FOR UPDATE - for positioned update.FOR FETCH - ensure read-onlyOPTIMIZE FOR - requests special optimization.

DMLDML

Page 74: DB2 Online

04/09/23

SELECT SELECT EXAMPLESEXAMPLES

EXITEXIT>><<

8943 SELECT ORDER_STATUS_CODE , ORDER_ERROR_CD_DA , INPT_TYP_CD INTO : H , : H , : H FROM Y5SOBI0Y WHERE SRV_ORD_CNTRL_NO = : H

10279 SELECT COUNT ( * ) INTO : H FROM Y5SOBI0Y WHERE SRV_ORD_CNTRL_NO > '99000000000' AND ORDER_STATUS_CODE IN ( 'ER' , 'BT' , 'MC' , 'RD' )

DMLDML

Page 75: DB2 Online

04/09/23

SELECT SELECT EXAMPLESEXAMPLES

EXITEXIT>><<

239 DECLARE Y5SOAR0Y-CURSOR CURSOR FOR SELECT SRV_ORD_CNTRL_NO , SEGMENT_NUMBER , TAG_ID , TAG_QUALIFIER_ID , TAG_VALUE , TAG_BYPASS_IND FROM Y5SOAR0Y WHERE ( SRV_ORD_CNTRL_NO = : H ) AND ( TAG_ID = 'RCNUM') ORDER BY TAG_VALUE

DMLDML

Page 76: DB2 Online

04/09/23

SELECT SELECT EXAMPLESEXAMPLES

EXITEXIT>><<

577 SELECT COUNT ( * ) INTO : H FROM XIRM042Y WHERE EXISTS ( SELECT * FROM XIRM041Y WHERE SPLR_ID = : H AND USG_ID = XIRM042Y . USG_ID AND TRMSN_TMSTMP < : H AND ( INIT_ASSN_TMSTMP > : H OR EXISTS ( SELECT * FROM XIRM040Y WHERE SPLR_ID = : H AND CTN_ID = XIRM041Y . USG_ID ) ) )

(See View Definitions on next page)

DMLDML

Page 77: DB2 Online

04/09/23

SELECT SELECT EXAMPLESEXAMPLES

EXITEXIT>><<

CREATE VIEW CORPD000.XIRM042V AS SELECT ALL A.SPLR_ID, A.USG_ID FROM CORPD000.XY4BTB1T A, CORPD000.XY4BTB2T B WHERE A.SPLR_ID = B.SPLR_ID

AND A.USG_ID = B.USG_ID

CREATE VIEW CORPD000.XIRM041V AS SELECT ALL SPLR_ID, USG_ID, TRMSN_TMSTMP, INIT_ASSN_TMSTMP

FROM CORPD000.XY4BTB1T

CREATE VIEW CORPD000.XIRM040V AS SELECT ALL TRNSCTN_ID, TRNSCTN_SEQ_NO, SPLR_ID FROM CORPD000.XY4DSA2T

DMLDML

Page 78: DB2 Online

04/09/23

SELECT SELECT EXAMPLESEXAMPLES

EXITEXIT>><<

297 SELECT PKST . PK_ID , PKST . TRMSN_PK_NO INTO : H , : H FROM XIRZ017Y PKST WHERE ( PKST . SPLR_ID = : H AND PKST . FIL_TYP = : H AND PKST . SPLR_LOCN_ID = : H AND PKST . BILL_ACCTG_OFC_CD = : H AND PKST . SND_ACCTG_OFC_CD = : H AND PK_ID IN (SELECT MAX ( PK_ID ) FROM XIRZ017Y WHERE SPLR_ID = : H AND FIL_TYP = : H AND SPLR_LOCN_ID = : H AND BILL_ACCTG_OFC_CD = : H AND SND_ACCTG_OFC_CD = : H ) )

(See View Definition on next page)

DMLDML

Page 79: DB2 Online

04/09/23

SELECT SELECT EXAMPLESEXAMPLES

EXITEXIT<<

CREATE VIEW CORPD000.XIRZ017V AS SELECT A.SPLR_ID, A.TRMSN_TMSTMP, A.TRMSN_SEQ_NO, FIL_TYP, SPLR_LOCN_ID, PK_ID, PK_SEQ_NO, PK_OBLGTN_ID, TRMSN_PK_NO, CO_NO, BILL_ACCTG_OFC_CD, SND_ACCTG_OFC_CD, INDEP_EXCH_CARR_NO, INDEP_EXCH_CARR_CD FROM CORPD000.XZ4AUA1T A, CORPD000.XZ4AUA2T B WHERE A.SPLR_ID = B.SPLR_ID AND A.TRMSN_TMSTMP = B.TRMSN_TMSTMP AND A.TRMSN_SEQ_NO = B.TRMSN_SEQ_NO AND NOT EXISTS (SELECT ERRR_CD FROM CORPD000.XY4DSA2T C WHERE C.ERRR_CD IN (SELECT D.ERRR_CD FROM CORPD000.XY4DSC6T D WHERE A.SPLR_ID = D.SPLR_ID AND D.PROG_ID = 'XIRZ5020' AND D.FUNC_ID = 'TRANSACC' ) AND B.SPLR_ID = C.SPLR_ID AND B.PK_ID = C.TRNSCTN_ID AND B.PK_SEQ_NO = C.TRNSCTN_SEQ_NO)

DMLDML

Page 80: DB2 Online

04/09/23

DB2 Internal DB2 Internal FunctionsFunctions

MAIN MENUMAIN MENU>> EXITEXIT

Page 81: DB2 Online

04/09/23

DB2 THREAD DB2 THREAD CREATION CREATION

EXITEXITInternal FunctionsInternal Functions>>

Every DB2 program must be connected to DB2 by an attachment facility (TSO, CICS, IMS, CAF), which is the mechanism by which an environment is connected to a DB2 subsystem. Additionally, a thread must be established for each embedded SQL program that is executing. A thread is a control structure used by DB2 to communicate with an application program.

The thread is used to send requests to DB2, to send data from DB2 to the program, and to communicate (through the SQLCA - SQL Communication Area) the status of each SQL Statement after it is executed. Every program must communicate with DB2 by means of a thread.

Page 82: DB2 Online

04/09/23

DB2 THREAD DB2 THREAD CREATIONCREATION

EXITEXIT>><<

After the thread is established, DB2 loads the executable form of theapplication plan from the DB2 Directory (DSNDB01), whereit is physically stored as a Skeleton Cursor Table (SKCT). Theappropriate sections of each DBRM (Data Base Request Module)are loaded into an area of memory reserved for DB2 programexecution called the Environmental Descriptor Management Pool(EDM Pool). All Database Descriptors (DBDs) required by theplan are also loaded into the EDM Pool.

Internal FunctionsInternal Functions

Page 83: DB2 Online

04/09/23

DB2 Internal FunctionsDB2 Internal Functions

>><< EXITEXIT

Application Program:Works with Columns

Relational Database System:Works with Columns (Stage 2)

Data Manager:Works with Rows (Stage 1)

Buffer Manager:Works with Bufferpool Pages

Media Manager:Works with DASD Pages

Application

RDS

DM

BM

MM

DASD

Internal FunctionsInternal Functions

Page 84: DB2 Online

04/09/23 EXITEXIT>><<

DB2 Internal FunctionsDB2 Internal Functions

Media Manager -Media Manager - When a requested page is not found in the When a requested page is not found in the

bufferpool (or Hiperpool), the Media Manager issues the I/O Request to obtain bufferpool (or Hiperpool), the Media Manager issues the I/O Request to obtain the page from DASD which it then returns to the Buffer Manager. the page from DASD which it then returns to the Buffer Manager.

Buffer Manager - Buffer Manager - When an index or data page is requested by When an index or data page is requested by the Data Manager, the Buffer Manager does a hash search (i.e. very fast) the Data Manager, the Buffer Manager does a hash search (i.e. very fast) through the bufferpool to find the page. If it is not found, the Hiperpool is through the bufferpool to find the page. If it is not found, the Hiperpool is then hash searched for the requested page. If the page is in the Hiperpool, it is then hash searched for the requested page. If the page is in the Hiperpool, it is moved either by the Asynchronous Data Mover Facility (ADMF) or the MVS moved either by the Asynchronous Data Mover Facility (ADMF) or the MVS Move Page instruction. If the page is not in the Hiperpool, the Buffer Move Page instruction. If the page is not in the Hiperpool, the Buffer Manager requests the page from the Media Manager.Manager requests the page from the Media Manager.

Internal FunctionsInternal Functions

Page 85: DB2 Online

04/09/23 EXITEXIT<<

DB2 Internal FunctionsDB2 Internal Functions

Data Manager -Data Manager - The Data Manager works on rows of data and The Data Manager works on rows of data and

acquires those rows from the Buffer Manager through the use of Stage 1 acquires those rows from the Buffer Manager through the use of Stage 1 Predicates from the SQL Statement. The more rows that can be filtered out at Predicates from the SQL Statement. The more rows that can be filtered out at the Data Manager level, the less overall CPU it takes to satisfy the SQL the Data Manager level, the less overall CPU it takes to satisfy the SQL Query. Query.

Relation Data System - Relation Data System - Any predicates that have not Any predicates that have not been satisfied by the Data Manager are taken care of within the Relational been satisfied by the Data Manager are taken care of within the Relational Data System and are referred to as Stage 2 Predicates. The Relational Data Data System and are referred to as Stage 2 Predicates. The Relational Data System works on specific columns (based on the SQL Statement) in System works on specific columns (based on the SQL Statement) in preparation to passing those columns to the application program. Typically, preparation to passing those columns to the application program. Typically, the more Stage 2 Predicates there are, the more CPU is required to satisfy the the more Stage 2 Predicates there are, the more CPU is required to satisfy the query.query.

Internal FunctionsInternal Functions

Page 86: DB2 Online

04/09/23

DB2 COMMANDS & DB2 COMMANDS & UTILITIESUTILITIES

EXITEXITMAIN MENUMAIN MENU

COMMANDS - COMMANDS - Bind, Rebind, Bind, Rebind, Display, Free, Display, Free, Start, Stop, Term Utility Start, Stop, Term Utility

UTILITIES - UTILITIES - Copy, Load, Quiesce, Copy, Load, Quiesce, Recover, Recover, Reorg, RunstatsReorg, Runstats

DB2 CommandsDB2 Commands

DB2 UtilitiesDB2 Utilities

Page 87: DB2 Online

04/09/23

BIND PLANBIND PLAN

EXITEXITCommandsCommands>><<

The DSN subcommand BIND PLAN builds an application plan. AllDB2 programs require an application plan to allocate DB2 resourcesand support SQL requests made during execution.

READY DSN SYSTEM (DBJO) DSN BIND PLAN(XCS02700) MEMBER(XCS02700, XCS0GONG) ACTION(REPLACE) RETAIN ISOLATION(CS) VALIDATE(BIND) ACQUIRE(USE) RELEASE(COMMIT) LIBRARY('SUB.#NM.DBRMLIB') EXPLAIN(YES)

Note - need BIND, owner, BINDADD, BINDAGENT, SYSCTRL, or SYSADM Authority.

Page 88: DB2 Online

04/09/23

REBIND REBIND PLANPLAN

EXITEXIT>><<

The DSN subcommand REBIND PLAN rebinds an application planwhen changes have been made affect the plan, but the SQL statementsin the programs have not changed (ex. a new index has been added orRunstats has been run). REBIND PLAN is generally faster thanBIND PLAN but if any SQL statements have been changed or if aprogram is recompiled, use BIND PLAN with theACTION(REPLACE) keyword.

CommandsCommands

Page 89: DB2 Online

04/09/23

REBIND PLANREBIND PLAN

EXITEXIT>><<

READY DSN SYSTEM (DBJO) DSN REBIND PLAN(XCS02700) ISOLATION(CS) * VALIDATE(BIND) * ACQUIRE(USE) * RELEASE(COMMIT) * EXPLAIN(YES) *

* - Default is the value last time the plan was bound.

Note - need BIND, owner, BINDAGENT, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 90: DB2 Online

04/09/23

BIND BIND PACKAGEPACKAGE

EXITEXIT>><<

The DSN subcommand BIND PACKAGE builds an applicationpackage. For DB2 the description of the package is recorded inthe catalog and a prepared package is saved in the directory.

CommandsCommands

Page 91: DB2 Online

04/09/23

BIND BIND PACKAGEPACKAGE

EXITEXIT>><<

READY DSN SYSTEM (DBJO) DSN BIND PACKAGE(location-name.collection-id) OWNER(auth-id)/QUALIFIER(qualifier-name) MEMBER(member-name) LIBRARY(lib-name) ACTION(REPLACE/ADD VALIDATE(RUN/BIND) ISOLATION(RR/CS) RELEASE(COMMIT/DEALLOCATE) EXPLAIN(NO/YES) CURRENTDATA(NO/YES) ACQUIRE(USE) - required for packages

Note - need BIND, owner, BINDADD, BINDAGENT, PACKADM, SYSCTRL, or SYSADM.

CommandsCommands

Page 92: DB2 Online

04/09/23

REBIND REBIND PACKAGEPACKAGE

EXITEXIT>><<

The DSN subcommand REBIND PACKAGE rebinds an applicationpackage when changes have been made that affect the package,but the SQL statements in the program have not changed (ex. a new index is added or Runstats was run). REBIND PACKAGE isgenerally faster than BIND PACKAGE but if the SQL statementshave changed or the program has been recompiled, use BINDPACKAGE with the ACTION(REPLACE) parameter.

CommandsCommands

Page 93: DB2 Online

04/09/23

REBIND REBIND PACKAGEPACKAGE

EXITEXIT>><<

READY DSN SYSTEM (DBJO) DSN REBIND PACKAGE(location-name.collection-id) OWNER(auth-id)/QUALIFIER(qualifier-name) MEMBER(member-name) LIBRARY(lib-name) VALIDATE(RUN/BIND) * ISOLATION(RR/CS) * RELEASE(COMMIT/DEALLOCATE) * EXPLAIN(NO/YES) *

* - Default is the value last time the package was bound.

Note - need BIND, owner, BINDAGENT, PACKADM, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 94: DB2 Online

04/09/23

DISPLAY DISPLAY DATABASEDATABASE

EXITEXIT>><<

The DB2 DISPLAY DATABASE command displays informationabout the status of DB2 databases, tablespaces, tables, indexes, andpartitions.

DISPLAY DATABASE (database-name ,) * name1:name2 name* SPACENAM (space-name ,) USE LOCK * name1:name2 name* CLAIMERS AFTER LIMIT (50) ACTIVE * int RESTRICT

CommandsCommands

Page 95: DB2 Online

04/09/23

DISPLAY DISPLAY DATABASEDATABASE

EXITEXIT>><<

DISPLAY DATABASE (continued)

database-name - name of at least one database (or *).name1:nam2 - range of database/space names.name* - partial name of database/space.USE - correlation-id, connection-id, auth-id.LOCKS - transaction locks for tables and indexes.CLAIMERS - claims on tables and indexes.AFTER - collates after a database/space name.LIMIT - limits the number displayed.ACTIVE - displays allocated spaces.int - integer value 50 or less.RESTRICT - limits spaces to those in restricted mode.

Note - need DISPLAY, DISPLAYDB, DBMAINT, DBCTRL, DBADM, SYSOPR, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 96: DB2 Online

04/09/23

DISPLAY DATABASE DISPLAY DATABASE EXAMPLEEXAMPLE

EXITEXIT>><<

-DIS DB(UCBSO02Q) SPACENAM(UCBSO02S)

DSNT360I - ***************************************************DSNT361I - * DISPLAY DATABASE SUMMARY * GLOBAL DSNT360I - ***************************************************DSNT362I - DATABASE = UCBSO02Q STATUS = RW DBD LENGTH = 32294 DSNT397I - NAME TYPE PART STATUS -------- ---- ---- ------------------ -------- -------- ------ UCBSO02S TS RW ******* DISPLAY OF DATABASE UCBSO02Q ENDED **************

DSN9022I - DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION

CommandsCommands

Page 97: DB2 Online

04/09/23

DISPLAY DATABASE DISPLAY DATABASE EXAMPLEEXAMPLE

EXITEXIT>><<

-DIS DB(XXDJC00D) SPACENAM(*) RESTRICT

DSNT360I - ***************************************************DSNT361I - * DISPLAY DATABASE SUMMARY * RESTRICTED DSNT360I - ***************************************************DSNT362I - DATABASE = XXDJC00D STATUS = RW DBD LENGTH = 12104 DSNT397I - NAME TYPE PART STATUS -------- ---- ---- ------------------ -------- -------- ------XXDJCBSS TS RW,COPY XXDJCFTS TS RW,COPY XXDJCJPS TS RW,COPY XXDJCRES TS RW,COPY ******* DISPLAY OF DATABASE XXDJC00D ENDED ***************

DSN9022I - DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION

CommandsCommands

Page 98: DB2 Online

04/09/23

DISPLAY DISPLAY THREADTHREAD

EXITEXIT>><<

The DB2 DISPLAY THREAD command displays current statusinformation about DB2 threads. A DB2 thread is either an alliedthread or a database access thread and is active, inactive, or indoubt.Distributed threads have a connection with a remote location(active or inactive) or had a connection with a remote location(indoubt). An allied thread may or may not be distributed but adatabase access thread (DBAT) is always distributed.

CommandsCommands

Page 99: DB2 Online

04/09/23

DISPLAY DISPLAY THREADTHREAD

EXITEXIT>><<

DISPLAY THREAD (connection-name ,) * TYPE (ACTIVE) INDOUBT INACTIVE *

LOCATION (location-name ,) DETAIL * LUWID (luwid) token

CommandsCommands

Page 100: DB2 Online

04/09/23

DISPLAY DISPLAY THREADTHREAD

EXITEXIT>><<

DISPLAY THREAD (continued)

connection-name - one or more connection names (or *)TYPE - ACTIVE - only active threads. - INDOUBT - two-phase commit. - INACTIVE - only inactive threads. - * - all threads.LOCATION - limits display to distributed threads.location-name - specific distributed location ( or *) LUWID - fully qualified LUnetwork nametoken - up to 5 digit decimal id for luwidDETAIL - additional conversation activity info.

Note - need DISPLAY, SYSOPR, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 101: DB2 Online

04/09/23

DISPLAY THREAD DISPLAY THREAD EXAMPLEEXAMPLE

EXITEXIT>><<

-DIS THREAD(*)DSNV401I - DISPLAY THREAD REPORT FOLLOWS - DSNV402I - ACTIVE THREADS - NAME ST A REQ ID AUTHID PLAN ASIDDB2CALL T 63 DBJBGATE SRUO G4DB2PLN 002CDB2CALL T 28118 DBJBMGR DBJBMGR 0055#RB N 0 0159#RB N 2 IMSRBCTL 0114#RG N 1574 0009XCF06000 KPURCEL 0138#RG N 637 0006XBF0EF00 CMATHIA 00AF#RG N 2 IMSRGCTL 0154#RH N 164 0001XBF0QX00 MMANNA 0097#RH N 32 0009XCF00200 IN1800AD 00B5#RH N 2 IMSRHCTL 00B2TSO TR 55 MKENT MKENT PEBR 009D V444-USWDEN.DD019.AC4072837B3C=8631 ACCESSING DATA AT V446-DBJN DBJM TSO T * 3 MWINGFI MWINGFI 0151TSO T 5 BXGOMEZ BXGOMEZ PEBR 015ABATCH N 1 MROJAK 009FDISPLAY ACTIVE REPORT COMPLETE

DSN9022I - DSNVDT '-DIS THREAD' NORMAL COMPLETION

CommandsCommands

Page 102: DB2 Online

04/09/23

DISPLAY DISPLAY UTILITYUTILITY

EXITEXIT>><<

The DB2 DISPLAY UTILITY command displays the status of utilityjobs. A job can be active, stopped, or terminating. One set ofmessages is returned for each job identified by the command.

DISPLAY UTILITY (utility-id) partial-id* *

utility-id - identifies a single utility job by its UID parameter.partial-id* - identifies a set of utility jobs.* - all utility jobs.

Note - need DISPLAY, SYSOPR, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 103: DB2 Online

04/09/23

DISPLAY UTILITY DISPLAY UTILITY EXAMPLEEXAMPLE

EXITEXIT>><<

-DIS UTIL(*)

DSNU100I - DSNUGDIS - USERID = USWC125 UTILID = LOADSMF PROCESSING UTILITY STATEMENT 10 UTILITY = LOAD PHASE = BUILD COUNT = 0 STATUS = STOPPED

DSNU100I - DSNUGDIS - USERID = JCASTIN UTILID = JCASTIN.X4DRA4LD PROCESSING UTILITY STATEMENT 1 UTILITY = LOAD PHASE = BUILD COUNT = 0 -DIS UTIL(*)STATUS = STOPPED

DSN9022I - DSNUGCCC '-DIS UTIL' NORMAL COMPLETION

CommandsCommands

Page 104: DB2 Online

04/09/23

FREE FREE PACKAGEPACKAGE

EXITEXIT>><<

The DSN FREE PACKAGE subcommand can be used to delete a specificversion of a package, all versions, or whole collections of packages. Itdeletes corresponding table entries from the SYSIBM.SYSPACKAGEScatalog tables. Authorization for a package name is only removed when allversions of a package are deleted. This subcommand does not proceed untilall currently executing applications using the package finish executing.

FREE PACKAGE location-name.collection-id.package-id.version-id * * *location-name - location of the DBMS.collection-id - name of the collection of packages.package-id - specific package to be deleted.version-id - specific version of the package.* - indicates all (better not).

Note - need BINDAGENT, SYSCTRL, SYSADM Authority.

CommandsCommands

Page 105: DB2 Online

04/09/23

FREE PACKAGE FREE PACKAGE EXAMPLEEXAMPLE

EXITEXIT>><<

FREE PACKAGE dbjr.tollcol1.*

Frees all packages within collection (tollcol1) on COTHOR.

FREE PACKAGE dbjm.xirdc00c.xirm1000.*

Frees all versions of package (xirm1000) in collection (xirdc00c) on COACCT.

CommandsCommands

Page 106: DB2 Online

04/09/23

FREE PLANFREE PLAN

EXITEXIT>><<

The DSN FREE PLAN subcommand deletes application plans from DB2.It deletes corresponding table entries from the SYSIBM.SYSPLANS catalogtables. All authorization for an application plan name is dropped. Thissubcommand does not proceed until all currently executing applicationsusing the package finish executing.

FREE PLAN (plan-name ,) *

plan-name - lists the names of one or more plans to delete.* - indicates all (don't even think about it).

Note - need BIND, BINDAGENT, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 107: DB2 Online

04/09/23

FREE PLAN FREE PLAN EXAMPLEEXAMPLE

EXITEXIT>><<

FREE PLAN (XIRB1000, XIRB2000)

Frees plans XIRB1000 and XIRB2000 and angers RIB.

CommandsCommands

Page 108: DB2 Online

04/09/23

START START DATABASEDATABASE

EXITEXIT>><<

The DB2 START DATABASE command is typically used after a previousSTOP DATABASE command or after a tablespace or index has been placedin deferred restart status by DB2. It makes the specified database availablefor use. Depending on the options specified, a database can be startedread-only, read-write (normal) or utility-only.

START DATABASE (database-name ,) * (database-name) SPACENAM(space-name ,) * PART(integer ,) ACCESS(RW) RO UT FORCE

CommandsCommands

Page 109: DB2 Online

04/09/23

START START DATABASEDATABASE

EXITEXIT>><<

START DATABASE (continued)

database-name - name of the database.space-name - name of tablespace or indexspace.integer - partition numberRW - Read/Write (normal default)RO - Read OnlyUT - UtilityFORCE - Resets all flags so be cautious.

Note - need STARTDB, DBMAINT, DBCTRL, DBADM, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 110: DB2 Online

04/09/23

STOP STOP DATABASEDATABASE

EXITEXIT>><<

The DB2 STOP DATABASE command makes the specified databaseunavailable for applications and closes the datasets. Tablespacesand indexes that are explicitly stopped with this command mustbe explicitly started with the START DATABASE command.

STOP DATABASE

(database-name ,) * (database-name) SPACENAM(space-name ,) * PART(integer ,)

AT(COMMIT)

CommandsCommands

Page 111: DB2 Online

04/09/23

STOP STOP DATABASEDATABASE

EXITEXIT>><<

STOP DATABASE (continued)

database-name - name of the database.space-name - name of tablespace or indexspace.integer - partition numberCOMMIT - allows STOP command at commit.

Note - need STOPDB, DBMAINT, DBCTRL, DBADM, SYSCTRL, or SYSADM Authority.

CommandsCommands

Page 112: DB2 Online

04/09/23

TERM UTILITYTERM UTILITY

EXITEXIT<<

The DB2 TERM UTILITY command terminates execution of a utilityjob step and releases all resources associated with the step. Whenexecuting, a utility will not terminate until it checks to see if a TERMUTILITY was issued. This check is done periodically from activeutilities.

TERM UTILITY (utility-id) partial-id* *utility-id - identifies a single utility job by its UID parameter.partial-id* - identifies a set of utility jobs to terminate.* - all utility jobs (think again).

Note - need SYSOPR, SYSCTRL, SYSADM Authority or originator.

CommandsCommands

Page 113: DB2 Online

04/09/23

IMAGE COPY IMAGE COPY UTILITYUTILITY

EXITEXITUtilitiesUtilities>>

The COPY online utility creates up to four image copies of a tablespaceor a dataset within a tablespace. The Full Image Copy is a copy of allpages in a tablespace or dataset. The Incremental Image Copy is a copyonly of pages modified since the last use of the COPY utility.

COPY TABLESPACE database-name. tablespace-name

DSNUM ALL COPYDDN SYSCOPY integer

RECOVERYDDN(ddname)

FULL YES SHRLEVEL REFERENCE NO CHANGE

Page 114: DB2 Online

04/09/23

IMAGE COPY IMAGE COPY UTILITYUTILITY

EXITEXIT>><<

IMAGE COPY UTILITY (continued)

tablespace-name - name of tablespace to be copied.ALL - entire tablespace.integer - partition number.SYSCOPY - cataloged primary copy.ddname - recovery site DD name.YES - full image copy (default).NO - incremental image copy.REFERENCE - allows read-only access (default).CHANGE - allows updates.

Note - need IMAGCOPY, DBADM, DBCTRL, DBMAINT, SYSCTRL, or SYSADM Authority.

UtilitiesUtilities

Page 115: DB2 Online

04/09/23

LOAD UTILITYLOAD UTILITY

EXITEXIT>><<

The LOAD online utility loads data into one or more tables in a table-space, or one or more partitions of a tablespace, and can replace orappend the existing data in either case. The LOAD DATA statementdescribes the data to be loaded and provides resource allocation data.

LOAD DATA INDDN SYSREC ddname

RESUME NO REPLACE KEEPDICTIONARY RESUME YES LOG YES WORKDDN (SYSUT1,SORTOUT) NO ddname1,ddname2 . . SORTDEVT device-type SORTNUM integer

INTO TABLE table-name

UtilitiesUtilities

Page 116: DB2 Online

04/09/23

LOAD UTILITYLOAD UTILITY

EXITEXIT>><<

LOAD UTILITY (continued)

SYSREC - input record format.RESUME NO - loads into an empty table.RESUME YES - loads into a non-empty table at end.KEEPDICT... - retains compression dictionary.REPLACE - replaces all existing rows on table.LOG YES - all records loaded are logged.LOG NO - no logging - copy pending flag set.SYSUT1 - default sort input.SORTOUT - default sort output.device-type - DFSORT dynamic allocation.integer - number of temporary datasets.

Note - need LOAD, DBADM, DBCTRL, SYSCTRL, or SYSADM Authority.

UtilitiesUtilities

Page 117: DB2 Online

04/09/23

QUIESCE QUIESCE UTILITYUTILITY

EXITEXIT>><<

The QUIESCE utility establishes a consistency point (current log RBA)for a tablespace, partition, or list of tablespaces then records it in theSYSIBM.SYSCOPY catalog table.

QUIESCE TABLESPACE database-name.tablespace-name

PART integer WRITE YES NO

database-name - name of the database (optional).tablespace-name - name of the tablespace to be quiesced.integer - partition number.WRITE YES - externalize changed pages to DASD.WRITE NO - don't externalize at transaction consistency. Note - need IMAGCOPY, DBADM, DBCTRL, DBMAINT, SYSCTRL, or SYSADM Authority.

UtilitiesUtilities

Page 118: DB2 Online

04/09/23

RECOVER INDEX RECOVER INDEX UTILITYUTILITY

EXITEXIT>><<

The RECOVER INDEX recreates indexes from the referenced table.

RECOVER INDEX (index-name PART integer ,) ALL

TABLESPACE database-name.tablespace-name PART integer

WORKDDN(SYSUT1) ddname

SORTDEVT device-type SORTNUM integer

UtilitiesUtilities

Page 119: DB2 Online

04/09/23

RECOVER INDEX RECOVER INDEX UTILITYUTILITY

EXITEXIT>><<

RECOVER INDEX UTILITY (continued)

index-name - name of the index to be recoveredALL - recover all defined indexes.PART integer - physical partition of partitioned index.database-name - name of the database.tablespace-name - name of the tablespace to be recovered.SYSUT1 - default temporary work file.ddname - DD name for the temporary work file.device-type - device type (i.e. DASD) of temporary datasets.SORTNUM - number of temporary datasets.

Note - need RECOVERDB, DBADM, DBCTRL, SYSCTRL, or SYSADM.

UtilitiesUtilities

Page 120: DB2 Online

04/09/23

RECOVER TABLESPACE RECOVER TABLESPACE UTILITYUTILITY

EXITEXIT>><<

The RECOVER TABLESPACE utility recovers an entire tablespace, adataset, pages within an error range, or a single page. The data isrecovered from image copies of a tablespace and the database logchange records. It does not recover indexes.

RECOVER TABLESPACE database-name.tablespace-name

DSNUM ALL integer

TORBA x'byte-string' LOGONLY

TOCOPY dataset-name

UtilitiesUtilities

Page 121: DB2 Online

04/09/23

RECOVER TABLESPACE RECOVER TABLESPACE UTILITYUTILITY

EXITEXIT>><<

RECOVER TABLESPACE UTILITY (continued)

database-name - name of the database.tablespace-name - name of the tablespace to be recovered.ALL - recovers entire tablespace (default).integer - number of the partition.x'byte-string' - HEX Relative Byte Address from the log.LOGONLY - applies on log records to the dataset.dataset-name - MVS generation dataset (fully qualified).

Note - need RECOVERDB, DBADM, DBCTRL, SYSCTRL, or SYSADM.

UtilitiesUtilities

Page 122: DB2 Online

04/09/23

REORG TABLESPACE REORG TABLESPACE UTILITYUTILITY

EXITEXIT>><<

The REORG TABLESPACE utility reorganizes a tablespace or a partitionimprove access performance and reclaim fragmented space.

REORG TABLESPACE database-name.tablespace-name

LOG YES SORTDATA KEEPDICTIONARY NO

PART integer UNLDDN SYSREC ddname

WORKDDN(SYSUT1 ,SORTOUT) ddname1 ,ddname2

SORTDEVT device-type SORTNUM integer1

UtilitiesUtilities

Page 123: DB2 Online

04/09/23

REORG TABLESPACE REORG TABLESPACE UTILITYUTILITY

EXITEXIT>><<

REORG TABLESPACE UTILITY (continued)

tablespace-name - name of the tablespace to be reorganized.LOG YES - logs records during the reload phase (default).LOG NO - no logging (turns on copy pending).SORTDATA - sort in clustering order.KEEP... - retains existing compression dictionary.PART integer - partition to be reorganized.SYSREC - default unload dataset.ddname - DD name of the unload dataset.WORKDDN - intermediate temporary dataset.

Note - need REORG, DBADM, DBCTRL, SYSCTRL, or SYSADM Authority.

UtilitiesUtilities

Page 124: DB2 Online

04/09/23

REORG INDEX REORG INDEX UTILITYUTILITY

EXITEXIT>><<

The REORG INDEX utility reorganizes an index or index partition toimprove access performance and reclaim fragmented space.

REORG INDEX index-name

PART integer UNLDDN SYSREC ddname

WORKDDN(SYSUT1 ,SORTOUT) ddname1 ,ddname2

SORTDEVT device-type SORTNUM integer1

UtilitiesUtilities

Page 125: DB2 Online

04/09/23

REORG INDEX REORG INDEX UTILITYUTILITY

EXITEXIT>><<

REORG INDEX UTILITY (continued)

index-name - name of the index to be reorganized.PART integer - partition to be reorganized.SYSREC - default unload dataset.ddname - DD name of the unload dataset.WORKDDN - intermediate temporary dataset.SYSUT1 - default sort input temporary dataset.SORTOUT - default sort output temporary dataset. ddname1 - sort input temporary dataset.ddname2 - sort output temporary dataset.device-type - DFSORT device type (i.e. DASD).integer1 - number of temporary sort datasets.

Note - need REORG, DBADM, DBCTRL, SYSCTRL, or SYSADM Authority.

UtilitiesUtilities

Page 126: DB2 Online

04/09/23

RUNSTATS TABLESPACE RUNSTATS TABLESPACE UTILITY UTILITY

EXITEXIT>><<

The RUNSTATS utility gathers summary information about thecharacteristics of the data in tablespaces, indexes, and partitionswhich is recorded in the DB2 Catalog and subsequently utilizedby DB2 to select access paths during the BIND process.

RUNSTATS TABLESPACE dbname.tsname PART integer

TABLE ALL (table-name) COLUMN ALL (col-name ,)

INDEX (ALL) SRHLEVEL REFERENCE (ixname PART int ,) CHANGE

REPORT NO UPDATE ALL YES ACCESSPATH

UtilitiesUtilities

Page 127: DB2 Online

04/09/23

RUNSTATS TABLESPACE RUNSTATS TABLESPACE UTILITYUTILITY

EXITEXIT>><<

RUNSTATS TABLESPACE UTILITY (continued)

dbname.tsname - database and tablespace name.PART integer - specific partition for runstats.TABLE ALL - all columns of all tables in tablespace.table-name - specific table name.COLUMN ALL - all columns within a specific table.col-name - specific column names.INDEX (ALL) - all defined indexes. ixname - specific index names.PART int - specific index partition.REFERENCE - allows read-only access by other programs.CHANGE - allows update access by other programs.REPORT - NO (updates) YES (no catalog updates).

Note - need STATS, DBADM, DBCTRL, DBMAINT, SYSCTRL, or SYSADM.

UtilitiesUtilities

Page 128: DB2 Online

04/09/23

RUNSTATS TABLESPACE RUNSTATS TABLESPACE UTILITY UTILITY

EXITEXIT>><<

RUNSTATS TABLESPACE UTILITY (continued)

dbname.tsname - database and tablespace name.PART integer - specific partition for runstats.TABLE ALL - all columns of all tables in tablespace.table-name - specific table name.COLUMN ALL - all columns within a specific table.col-name - specific column names.INDEX (ALL) - all defined indexes. ixname - specific index names.PART int - specific index partition.REFERENCE - allows read-only access by other programs.CHANGE - allows update access by other programs.REPORT - NO (updates) YES (no catalog updates).

Note - need STATS, DBADM, DBCTRL, DBMAINT, SYSCTRL, or SYSADM.

UtilitiesUtilities

Page 129: DB2 Online

04/09/23

RUNSTATS INDEX RUNSTATS INDEX UTILITYUTILITY

EXITEXIT>><<

The RUNSTATS INDEX utility gathers summary information on indexes.

RUNSTATS INDEX

( index-name PART integer ,) (ALL ) TABLESPACE dbname.tsname

SRHLEVEL REFERENCE CHANGE

REPORT NO UPDATE ALL YES ACCESSPATH SPACE NONE

UtilitiesUtilities

Page 130: DB2 Online

04/09/23

RUNSTATS INDEX RUNSTATS INDEX UTILITYUTILITY

EXITEXIT<<

RUNSTATS INDEX UTILITY (continued)

index-name - specific index name.PART integer - specific partitioned index.ALL - all indexes within the tablespace.dbname.tsname - database and tablespace name.PART integer - specific partition for runstats.REFERENCE - allows read-only access by other programs.CHANGE - allows update access by other programs.REPORT - NO (updates) YES (no catalog updates).UPDATE ALL - all collected statistics updated in catalog.ACCESSPATH - updates access path-related info only.SPACE - updates space-related info only.NONE - no updates (used with REPORT YES).

Note - need STATS, DBADM, DBCTRL, DBMAINT, SYSCTRL, or SYSADM.

UtilitiesUtilities

Page 131: DB2 Online

04/09/23

AppendixesAppendixes

Prefetch DefinitionsPrefetch Definitions DB2 Data TypesDB2 Data Types DB2 LimitsDB2 Limits DB2 Online ManualsDB2 Online Manuals DB2 Reference BooksDB2 Reference Books

EXITEXIT>><< MAIN MENUMAIN MENU

Data TypesData Types

PrefetchPrefetch

Online ManualsOnline Manuals

Reference BooksReference Books

DB2 LimitsDB2 Limits

Page 132: DB2 Online

04/09/23

PREFETCHPREFETCH

EXITEXITAppendixesAppendixes>><<

SEQUENTIAL - DB2 issues an I/O for the next 32 4K pages in the tablespace or index if the associated bufferpool has at least 1000 pages. Utilities can get up to 64 4K pages. The DB2 Explain will indicate sequential prefetch with an 'S' in the Prefetch Column.

LIST - DB2 checks to see how many of the requested pages for the qualifying rows are identical; then eliminates these duplicates before issuing the multiple I/Os. The DB2 Explain will indicate list prefetch with an ’L' in the Prefetch Column.

DYNAMIC - This is also referred to as Sequential Detection. If neither sequential or list prefetch is turned on, DB2 will keep track of the previous 8 ]/Os and if at least 5 of those I/Os are considered4sequential, DB2 will issue an I/O for the next 32 HK pages of the index or tablespace. DB2 will also disable dynamic prefetch if less than 5 of the last 8 I/Os are considered sequential or a COMMIT is issued.

Page 133: DB2 Online

04/09/23

DB2 Data DB2 Data TypesTypes

EXITEXITAppendixesAppendixes>><<

Data Type Size Value Range COBOL Picture

SMALLINT 2 bytes + 32,767 PIC S9(4) COMPINTEGER 4 bytes + 2,147,483,647 PIC S9(9) COMPREAL 4 bytes 5.4 x 10-79 to 7.2 x 1075 PIC USAGE COMP 1FLOAT(1..21) 4 bytes 5.4 x 10-79 to 7.2 x 1075 PIC USAGE COMP 1DOUBLE PRECISION 8 bytes 5.4 x 10-79 to 7.2 x 1075 PIC USAGE COMP 2FLOAT(22..53) 8 bytes 5.4 x 10-79 to 7.2 x 1075 PIC USAGE COMP 2DECIMAL(m,n) (m/2)+1 bytes 1-1031 to 1031-1 PIC S9(m-n)V9(n) COMP 3CHARACTER(n) n bytes max. 254 characters PIC X(n)VARCHAR(n) 2 to n+2 bytes max. 4,046 bytes 01 VARCHAR.

32,704 for 32K page 49 LTH PIC S9(4) COMP. 49 COLUMN PIC X(n).

GRAPHIC(n) 2n bytes max. 127 chars. PIC G(n) DISPLAY 1VARGRAPHIC(n) 2 to 2n+2 bytes max. 2,023 chars. 01 VARCHAR. 49 LTH PIC S9(4) 49 COLUMN PIC G(n) DATE 4 bytes 0001-01-01 to 9999-12-31 PIC X(10)TIME 3 bytes 00.00.00 to 24.00.00 PIC X(8)TIMESTAMP 10 bytes 0001-01-01.00.00.00.000000 to PIC X(26)

9999-12-31.24.00.00.000000

Page 134: DB2 Online

04/09/23

DB2 LimitsDB2 Limits

EXITEXITAppendixesAppendixes>><<

Stogroup name 8 bytesVolumes per Stogroup 133Database name 8 bytesMax no. of databases 65,279Authorization ID 8 bytesPartitions per tablespace

(non-LARGE) 64(LARGE) 254

Partition size (non-LARGE)1- 16 parts 4 Gigabytes17 - 32 parts 2 Gigabytes33 - 64 parts 1 Gigabytes

Partition size (LARGE)1 - 254 parts 4 Gigabytes

Segment size 64 pagesTablespace size 1,016 Gigabytes

Page 135: DB2 Online

04/09/23

DB2 LimitsDB2 Limits

EXITEXITAppendixesAppendixes>><<

Table name 18 bytesView name 18 bytesAlias name 18 bytesSynonym name 18 bytesColumn name 18 bytesCursor name 18 bytesHost identifier 64 bytesNo. base tables per view 15Max. columns per table/view 750Index name 18 bytesColumns per index 64Index columns size

(Partitioned) 40 bytes(non-Partitioned) 254 bytes

Page 136: DB2 Online

04/09/23

DB2 LimitsDB2 Limits

Plan name 8 bytesPackage name 8 bytesCollection name 18 bytesVersion name 64 bytesDBRM name 8 bytesCorrelation ID 18 bytesMax. row length 4056 bytesMax. rows per page 127 or 255 comp.Max. index levels 6Largest SQL statement 32,765 bytesPredicates per WHERE clause 300Predicates per HAVING clause 300Concurrent users 2,000Open datasets 10,000

EXITEXITAppendixesAppendixes>><<

Page 137: DB2 Online

04/09/23

DB2 Online DB2 Online ManualsManuals

EXITEXITAppendixesAppendixes>><<

The DB2 Version 5.1 Manuals are located on the Fourth Platforms serverin Bellevue:

itsblvf03\omega

(P_ivp\06_ComDocs\04_Software\04_Reference_Guides\DB2 Manuals\DB2 V5.1)

The Manuals are in PDF format and require Adobe Acrobat Reader 3.0 or later. The DB2 V5.1 folder contains the following manuals:

Application Programming & SQL GuideAdministration GuideCommand GuideUtility Guide & ReferenceSQL ReferenceMessages & Codes

Page 138: DB2 Online

04/09/23

DB2 Reference DB2 Reference BooksBooks

EXITEXITAppendixesAppendixes>><<

DB2 Developer’s Guide (Third Edition)by Craig Mullins -1997

DB2 for OS/390 Development for Performance by Gabrielle Wiorkowski - 1998

DB2 For The COBOL Programmer Version 4.1 (Vol. 1) by Curtis Garvin, Steve Eckols - 1999