Professional Documents
Culture Documents
7/10/2011
>
EXIT
7/10/2011
<
>
MAIN MENU
EXIT
Relational Database Physical Structures DDL DCL DML DB2 Internals Commands/Utilities Appendixes
<
>
EXIT
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.
7/10/2011
<
>
MAIN MENU
EXIT
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.
7/10/2011
<
>
MAIN MENU
EXIT
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.
7/10/2011
<
>
MAIN MENU
EXIT
7/10/2011
<
>
MAIN MENU
EXIT
7/10/2011
<
>
Physical Structures
EXIT
Tablespace - An area of External Storage assigned to hold a table. Table - Actual Rows and Columns of Data. Index - Consists of one or more VSAM datasets used to achieve more
efficient access to data pages and/or to ensure row uniqueness.
Synonym - An alternate, private name for a table or view. View - A logical, column-filtered, representation of a table. columnAlias - A type of global synonym for a table.
7/10/2011
<
>
Physical Structures
EXIT
<
>
Physical Structures
EXIT
SIMPLE Tablespace
Data Page
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.
7/10/2011
<
>
Physical Structures
EXIT
PARTITIONED Tablespace
PARTITION 1 3032210001 3032210002 3032210005 PART 1 Values (3039999999)
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.
7/10/2011
<
>
Physical Structures
EXIT
SEGMENTED Tablespace
Segment 1 Segment 2
Table A Rows
Table B Rows
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.
7/10/2011
<
>
Physical Structures
EXIT
Data Page n
Data Page 1
Space Map Page
Header Page
7/10/2011
<
>
Physical Structures
EXIT
Row Data
Row Data
<
>
Physical Structures
EXIT
For 4K Pages, a Space Map controls 1712 pages for Segment Size of 4 ... up to 5504 pages for Segment Size of 64.
7/10/2011
<
>
Physical Structures
EXIT
Index Page n
Index Page 1
Space Map Page
Header Page
<
>
Physical Structures
EXIT
RID
5 Bytes
Key
RID
Free Space
1 Byte Trailer
7/10/2011
<
>
Physical Structures
EXIT
Balanced Tree
LEAF PAGE
LEAF PAGE
LEAF PAGE
7/10/2011
Primary Key - Indicates Referential Integrity; i.e. Parent Table. Integrity; Foreign Key - Indicates Referential Integrity; i.e. Dependent (or Integrity;
Child) Table.
7/10/2011
<
Physical Structures
EXIT
ALTER - Tablespace, Table, Index, Stogroup DROP - Database, Tablespace, Table, Index,
Synonym, View, Alias, Stogroup
ALTER DDL
DROP DDL
7/10/2011
MAIN MENU
EXIT
CREATE DATABASE
A DATABASE is related tables and indexes and their spaces grouped to facilitate handling.
CREATE DATABASE CRISAPDB STOGROUP CRISGRP1 BUFFERPOOL BP0
7/10/2011
>
DDL
EXIT
CREATE TABLESPACE
A TABLESPACE is an area of external storage assigned 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
< > DDL EXIT
7/10/2011
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 ********************************
7/10/2011
<
>
DDL
EXIT
CREATE TABLE
CREATE TABLE CORPD000.CRISAPTT (CUST_ACCT_ID CHAR(24) UNIV_SRV_ORD_CD CHAR(5) PROD_INTRNL_SER_ID CHAR(10) NOT NULL, NOT NULL, NOT NULL,
. . .
PROD_DISC_DAT DATE NOT NULL) (optional referential constraints) IN CRISAPDB.CRISAPTS
7/10/2011
<
>
DDL
EXIT
PROD_INTRNL_SER_ID PROD_DISC_DAT 5201400470 5201408956 5201408957 5201408958 5201408959 5202810420 5201408916 5201408840 5201408808 5201408809 5202810602 2099-12-31 2099-12-31 2099-12-31 2099-12-31 2099-12-31 2099-12-31 2099-12-31 2099-12-31 2099-12-31 2099-12-31 2099-12-31
WAXSQ WAXSQ WAXSQ WAXSQ WAXSQ CPERN WAXSQ WAXSQ WAXSQ WAXSQ PYKMN
<
>
DDL
EXIT
CREATE INDEX
CREATE UNIQUE INDEX CORPD000.CRISAPT1 ON CORPD000.CRISAPTT (CUST_ACCT_ID PROD_DISC_DAT ASC, DESC) (default Ascending) (Descending) (in Kbytes) (in Kbytes) (Assigned Bufferpool) (after 31 pages, 1 empty) (freespace on the index page) (only one per table)
USING STOGROUP CRISGRP2 PRIQTY 54000 SECQTY 9000 ERASE NO BUFFERPOOL BP2 CLOSE NO FREEPAGE 31 PCTFREE 20 CLUSTER
7/10/2011
Note: Duplicate values are not allowed for this index key.
< > DDL EXIT
PARTITIONING
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
7/10/2011
<
>
DDL
EXIT
PARTITIONING
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
7/10/2011
<
>
DDL
EXIT
CREATE VIEW
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.
7/10/2011
<
>
DDL
EXIT
CREATE SYNONYM
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
7/10/2011
<
>
DDL
EXIT
CREATE ALIAS
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
7/10/2011
<
DDL
EXIT
ALTER TABLESPACE
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.
7/10/2011
>
DDL
EXIT
ALTER TABLE
ALTER TABLE CORPD000.CRISAPTT (add a column)
7/10/2011
<
>
DDL
EXIT
ALTER INDEX
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.
7/10/2011
<
DDL
EXIT
DROP
The DROP statement deletes a DB2 object. Except for storage 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 the object are invalidated.
7/10/2011
>
DDL
EXIT
DROP
DROP ALIAS DATABASE INDEX STOGROUP SYNONYM TABLE TABLESPACE VIEW PACKAGE alias-name database-name index-name stogroup-name synonym table-name database-name.tablespace-name view-name collection-id.package-id VERSION version-id
Note - need owner, DBADM, SYSCTRL, or SYSADM. Remember the cascade effect of dropping objects!
7/10/2011
<
DDL
EXIT
GRANT DCL
REVOKE DCL
7/10/2011
MAIN MENU
EXIT
GRANT
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
7/10/2011
<
>
DCL
EXIT
GRANT
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
7/10/2011
<
>
DCL
EXIT
<
>
DCL
EXIT
<
>
DCL
EXIT
7/10/2011
<
>
DCL
EXIT
7/10/2011
<
>
DCL
EXIT
7/10/2011
<
>
DCL
EXIT
BIND - Grants the BIND, REBIND and FREE privilege. EXECUTE - Grants the privilege to run programs using this plan. plan-name - Identifies the application plan.
7/10/2011
<
>
DCL
EXIT
7/10/2011
<
>
DCL
EXIT
<
>
DCL
EXIT
7/10/2011
<
>
DCL
EXIT
<
>
DCL
EXIT
7/10/2011
<
>
DCL
EXIT
<
DCL
EXIT
REVOKE
The REVOKE statement revokes privileges from authorization IDs. There is a separate form of the statement for each of these classes of privileges (see GRANT syntax): Collection Database Package Plan System Table/View Use
7/10/2011
>
DCL
EXIT
REVOKE
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.
7/10/2011
<
DCL
EXIT
7/10/2011
>
MAIN MENU
EXIT
INSERT
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 view-name ( column-name ,)
<
>
DML
EXIT
INSERT
INSERT (continued) table-name view-name column-name host-variable constant/literal NULL special-register subselect - name of the table. - logical name of the table. - unqualified column name of table. - output variable with an assigned value. - specifies a value( string/numeric). - represents the the null value. - specially defined storage area. - set of rows from a result set of a subselect.
7/10/2011
<
>
DML
EXIT
MASS INSERT
The mass INSERT can have a real impact on runtime performance. If the inserts are based on an ever increasing/ascending key, each time the index page becomes full that page is split with half of the entries staying and half moving to the new index page resulting in a 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 trackat-time pre-formatting by DB2 which further increased runtimes. In Version 4.1, this movement of half of the index entries no longer occurs and DB2 merely starts inserting into the next index page.
7/10/2011
<
>
DML
EXIT
MASS INSERT
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.
7/10/2011
<
>
DML
EXIT
UPDATE
The UPDATE statement updates the values of specified columns in rows of a table or view. Updating a row of a view also updates that row of the table on which the view is based. The view may not be a Join View.
UPDATE table-name view-name SET column-name=expression NULL ,
<
>
DML
EXIT
UPDATE
UPDATE (continued) table-name view-name column-name expression NULL search-condition cursor-name - name of the table. - logical name of the table. - unqualified column name of table. - specifies a value (not a column function). - represents the null value. - combination of operators and predicates. - identifies the declared cursor.
<
>
DML
EXIT
MASS UPDATE
The mass UPDATE can have a real impact on runtime performance. If the table contains variable length rows (i.e. contains columns defined as VARCHAR or the table has compression turned on), when a column(s) is changed/updated, the row may not fit on the same page 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 insert the row on a new page. Freespace, again plays an important part in whether the row is now situated very far from the old page which affects the organization of the overall table. Without suitable freespace, the cluster ratio of the data decreases rapidly and subsequent SQL may suffer performance degradation.
7/10/2011
<
>
DML
EXIT
MASS UPDATE
DO NOT UPDATE columns that are part of an index. This also causes DB2 to delete and re-insert the rows. A different way to look at it is don't include columns in an index that may undergo frequent updating. Version 4.1 included an UPDATE Procedure to help speed-up the mass updates. Also, in Version 4.1, UPDATEs can take advantage of Dynamic Prefetch.
7/10/2011
<
>
DML
EXIT
DELETE
The DELETE statement deletes rows from a table or view. Deleting a row from a view also deletes that row from the table on which the view 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 view-name search-condition cursor-name
7/10/2011
- name of the table. - logical name of the table. - combination of operators and predicates. - identifies the declared cursor.
MASS DELETE
The mass DELETE can have a real impact on runtime performance. If the tablespace is defined as SIMPLE or PARTITIONED (which is just a set of simple tablespaces), a mass delete (i.e. DELETE FROM TABLE-NAME with no WHERE CLAUSE - which deletes all rows) from a large table will run a long time and put quite a stress on the DB2 logs as each delete is logged. In this case, a far better way to delete all the rows of this type of table is to use the LOAD utility and load an empty dataset. The table is almost instantly (even magically) empty. If it is not desired to delete all rows, then run an UNLOAD of all the rows to keep; then run a LOAD (REPLACE) with that unloaded dataset.
7/10/2011
<
>
DML
EXIT
MASS DELETE
If the tablespace is defined as SEGMENTED, a mass delete is very fast because only the SPACE MAP pages are updated to reflect all the deleted rows. Again, if it is not desired to delete all rows (but a high percentage of the rows), use the UNLOAD/LOAD procedure previously outlined. In Version 4.1, DELETEs could take advantage of Dynamic Prefetch.
7/10/2011
<
>
DML
EXIT
COMMIT
The Unit Of Recovery in which the statement is executed is ended and a new unit of recovery is started for the process. All changes made during the unit of recovery are committed.
COMMIT WORK
JUST DO IT!
7/10/2011
<
>
DML
EXIT
SELECT
The SELECT INTO statement produces a result table containing at most one row and assigns the values in that row to host variables. If the result table is empty, the statement assigns +100 to SQLCODE and does not assign any value to the host variables.
select-clause INTO host-variable , from-clause where-clause select-clause host-variable from-clause where-clause - see appropriate layout. - compatible data type program variable. - see appropriate layout. - see appropriate layout.
<
>
DML
EXIT
selectselect-clause
The SELECT clause specifies the columns of the final result table.
SELECT ALL DISTINCT * expression
- retains all rows of final result table (default). - eliminates duplicate rows from result table. - indicates all columns. - any expression.
7/10/2011
<
>
DML
EXIT
fromfrom-clause
The FROM clause specifies an intermediate result table. If a single table or view is identified, the intermediate result table is simply that table or view. If more than one table or view is identified, the intermediate result table consists of all possible combinations of the rows of the identified table or views. If any table or view is empty, the result is empty.
FROM table-name , view-name table-name view-name
7/10/2011
<
>
DML
EXIT
wherewhere-clause
The WHERE clause specifies an intermediate result table that consists of those rows of the result table for which the search condition is true.
WHERE search-condition predicate (search-condition) predicate (search-condition)
NOT
<
>
DML
EXIT
DECLARE CURSOR
The DECLARE CURSOR statement declares a cursor and can only be embedded in an application program.
DECLARE FOR cursor-name full-select ORDER BY FOR UPDATE OF FOR FETCH ONLY OPTIMIZE FOR CURSOR WITH HOLD
7/10/2011
<
>
DML
EXIT
DECLARE CURSOR
DECLARE CURSOR (continued) cursor-name WITH HOLD full-select ORDER BY FOR UPDATE FOR FETCH OPTIMIZE FOR - name of the cursor. - cursor not closed at commit point. - select-clause, from-clause, where-clause. - orders the rows of the result table. - for positioned update. - ensure read-only - requests special optimization.
7/10/2011
<
>
DML
EXIT
SELECT EXAMPLES
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' )
7/10/2011
<
>
DML
EXIT
SELECT EXAMPLES
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
7/10/2011
<
>
DML
EXIT
SELECT EXAMPLES
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)
7/10/2011
<
>
DML
EXIT
SELECT EXAMPLES
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
7/10/2011
<
>
DML
EXIT
SELECT EXAMPLES
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)
7/10/2011
<
>
DML
EXIT
SELECT EXAMPLES
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) 7/10/2011
<
DML
EXIT
7/10/2011
>
MAIN MENU
EXIT
7/10/2011
>
Internal Functions
EXIT
7/10/2011
<
>
Internal Functions
EXIT
RDS DM BM MM
7/10/2011
DASD
<
>
Internal Functions
EXIT
Relation Data System - Any predicates that have not 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 System works on specific columns (based on the SQL Statement) in 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 query.
7/10/2011
<
Internal Functions
EXIT
DB2 Commands
DB2 Utilities
7/10/2011
MAIN MENU
EXIT
BIND PLAN
The DSN subcommand BIND PLAN builds an application plan. All DB2 programs require an application plan to allocate DB2 resources and 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.
7/10/2011
<
>
Commands
EXIT
REBIND PLAN
The DSN subcommand REBIND PLAN rebinds an application plan when changes have been made affect the plan, but the SQL statements in the programs have not changed (ex. a new index has been added or Runstats has been run). REBIND PLAN is generally faster than BIND PLAN but if any SQL statements have been changed or if a program is recompiled, use BIND PLAN with the ACTION(REPLACE) keyword.
7/10/2011
<
>
Commands
EXIT
REBIND PLAN
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.
7/10/2011
<
>
Commands
EXIT
BIND PACKAGE
The DSN subcommand BIND PACKAGE builds an application package. For DB2 the description of the package is recorded in the catalog and a prepared package is saved in the directory.
7/10/2011
<
>
Commands
EXIT
BIND PACKAGE
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.
7/10/2011
<
>
Commands
EXIT
REBIND PACKAGE
The DSN subcommand REBIND PACKAGE rebinds an application package 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 is generally faster than BIND PACKAGE but if the SQL statements have changed or the program has been recompiled, use BIND PACKAGE with the ACTION(REPLACE) parameter.
7/10/2011
<
>
Commands
EXIT
REBIND PACKAGE
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.
7/10/2011
* * * *
<
>
Commands
EXIT
DISPLAY DATABASE
The DB2 DISPLAY DATABASE command displays information about the status of DB2 databases, tablespaces, tables, indexes, and partitions.
DISPLAY DATABASE (database-name ,) * name1:name2 name* SPACENAM (space-name ,) USE LOCK * name1:name2 name* CLAIMERS AFTER LIMIT (50) ACTIVE * int RESTRICT
< > Commands EXIT
7/10/2011
DISPLAY DATABASE
DISPLAY DATABASE (continued) database-name name1:nam2 name* USE LOCKS CLAIMERS AFTER LIMIT ACTIVE int RESTRICT - name of at least one database (or *). - range of database/space names. - partial name of database/space. - correlation-id, connection-id, auth-id. - transaction locks for tables and indexes. - claims on tables and indexes. - collates after a database/space name. - limits the number displayed. - displays allocated spaces. - integer value 50 or less. - limits spaces to those in restricted mode.
7/10/2011
Note - need DISPLAY, DISPLAYDB, DBMAINT, DBCTRL, DBADM, SYSOPR, SYSCTRL, or SYSADM Authority. < > Commands EXIT
7/10/2011
<
>
Commands
EXIT
<
>
Commands
EXIT
DISPLAY THREAD
The DB2 DISPLAY THREAD command displays current status information about DB2 threads. A DB2 thread is either an allied thread 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 a database access thread (DBAT) is always distributed.
7/10/2011
<
>
Commands
EXIT
DISPLAY THREAD
DISPLAY THREAD (connection-name ,) * TYPE (ACTIVE) INDOUBT INACTIVE * LOCATION (location-name ,) DETAIL * LUWID (luwid) token
7/10/2011
<
>
Commands
EXIT
DISPLAY THREAD
DISPLAY THREAD (continued) connection-name TYPE - one or more connection names (or *) - ACTIVE - only active threads. - INDOUBT - two-phase commit. - INACTIVE - only inactive threads. -* - all threads. - limits display to distributed threads. - specific distributed location ( or *) - fully qualified LUnetwork name - up to 5 digit decimal id for luwid - additional conversation activity info.
<
>
Commands
EXIT
7/10/2011
<
>
Commands
EXIT
DISPLAY UTILITY
The DB2 DISPLAY UTILITY command displays the status of utility jobs. A job can be active, stopped, or terminating. One set of messages 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.
7/10/2011
<
>
Commands
EXIT
7/10/2011
<
>
Commands
EXIT
FREE PACKAGE
The DSN FREE PACKAGE subcommand can be used to delete a specific version of a package, all versions, or whole collections of packages. It deletes corresponding table entries from the SYSIBM.SYSPACKAGES catalog tables. Authorization for a package name is only removed when all versions of a package are deleted. This subcommand does not proceed until all currently executing applications using the package finish executing.
FREE PACKAGE location-name collection-id package-id version-id * location-name.collection-id.package-id.version-id * * * - location of the DBMS. - name of the collection of packages. - specific package to be deleted. - specific version of the package. - indicates all (better not).
<
>
Commands
EXIT
FREE PACKAGE dbjm.xirdc00c.xirm1000.* Frees all versions of package (xirm1000) in collection (xirdc00c) on COACCT.
7/10/2011
<
>
Commands
EXIT
FREE PLAN
The DSN FREE PLAN subcommand deletes application plans from DB2. It deletes corresponding table entries from the SYSIBM.SYSPLANS catalog tables. All authorization for an application plan name is dropped. This subcommand does not proceed until all currently executing applications using 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.
7/10/2011
<
>
Commands
EXIT
FREE PLAN (XIRB1000, XIRB2000) Frees plans XIRB1000 and XIRB2000 and angers RIB.
7/10/2011
<
>
Commands
EXIT
START DATABASE
The DB2 START DATABASE command is typically used after a previous STOP DATABASE command or after a tablespace or index has been placed in deferred restart status by DB2. It makes the specified database available for use. Depending on the options specified, a database can be started read-only, read-write (normal) or utility-only.
START DATABASE (database-name ,) * (database-name) SPACENAM(space-name ,) * PART(integer ,) ACCESS(RW) RO UT FORCE
7/10/2011
<
>
Commands
EXIT
START DATABASE
START DATABASE (continued) database-name space-name integer RW RO UT FORCE - name of the database. - name of tablespace or indexspace. - partition number - Read/Write (normal default) - Read Only - Utility - Resets all flags so be cautious.
<
>
Commands
EXIT
STOP DATABASE
The DB2 STOP DATABASE command makes the specified database unavailable for applications and closes the datasets. Tablespaces and indexes that are explicitly stopped with this command must be explicitly started with the START DATABASE command.
STOP DATABASE (database-name ,) * (database-name) SPACENAM(space-name ,) * PART(integer ,) AT(COMMIT)
7/10/2011
<
>
Commands
EXIT
STOP DATABASE
STOP DATABASE (continued) database-name space-name integer COMMIT - name of the database. - name of tablespace or indexspace. - partition number - allows STOP command at commit.
7/10/2011
<
>
Commands
EXIT
TERM UTILITY
The DB2 TERM UTILITY command terminates execution of a utility job step and releases all resources associated with the step. When executing, a utility will not terminate until it checks to see if a TERM UTILITY was issued. This check is done periodically from active utilities.
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.
7/10/2011
<
Commands
EXIT
<
>
Utilities
EXIT
LOAD UTILITY
The LOAD online utility loads data into one or more tables in a tablespace, or one or more partitions of a tablespace, and can replace or append the existing data in either case. The LOAD DATA statement describes the data to be loaded and provides resource allocation data.
LOAD DATA INDDN SYSREC ddname REPLACE KEEPDICTIONARY WORKDDN (SYSUT1,SORTOUT) ddname1,ddname2
SORTNUM integer
<
>
Utilities
EXIT
LOAD UTILITY
LOAD UTILITY (continued) SYSREC RESUME NO RESUME YES KEEPDICT... REPLACE LOG YES LOG NO SYSUT1 SORTOUT device-type integer - input record format. - loads into an empty table. - loads into a non-empty table at end. - retains compression dictionary. - replaces all existing rows on table. - all records loaded are logged. - no logging - copy pending flag set. - default sort input. - default sort output. - DFSORT dynamic allocation. - number of temporary datasets.
<
>
Utilities
EXIT
QUIESCE UTILITY
The QUIESCE utility establishes a consistency point (current log RBA) for a tablespace, partition, or list of tablespaces then records it in the SYSIBM.SYSCOPY catalog table.
QUIESCE TABLESPACE database-name.tablespace-name PART integer WRITE YES NO - name of the database (optional). - name of the tablespace to be quiesced. - partition number. - externalize changed pages to DASD. - don't externalize at transaction consistency.
<
>
Utilities
EXIT
TABLESPACE database-name.tablespace-name PART integer WORKDDN(SYSUT1) ddname SORTDEVT device-type SORTNUM integer
7/10/2011
<
>
Utilities
EXIT
<
>
Utilities
EXIT
LOGONLY
<
>
Utilities
EXIT
<
>
Utilities
EXIT
<
>
Utilities
EXIT
<
>
Utilities
EXIT
PART integer UNLDDN SYSREC ddname WORKDDN(SYSUT1 ddname1 SORTDEVT device-type ,SORTOUT) ,ddname2 SORTNUM integer1
7/10/2011
<
>
Utilities
EXIT
<
>
Utilities
EXIT
,)
INDEX (ALL) SRHLEVEL REFERENCE (ixname PART int ,) CHANGE REPORT NO YES
7/10/2011
- database and tablespace name. - specific partition for runstats. - all columns of all tables in tablespace. - specific table name. - all columns within a specific table. - specific column names. - all defined indexes. - specific index names. - specific index partition. - allows read-only access by other programs. - allows update access by other programs. - NO (updates) YES (no catalog updates).
- database and tablespace name. - specific partition for runstats. - all columns of all tables in tablespace. - specific table name. - all columns within a specific table. - specific column names. - all defined indexes. - specific index names. - specific index partition. - allows read-only access by other programs. - allows update access by other programs. - NO (updates) YES (no catalog updates).
7/10/2011
<
- specific index name. - specific partitioned index. - all indexes within the tablespace. - database and tablespace name. - specific partition for runstats. - allows read-only access by other programs. - allows update access by other programs. - NO (updates) YES (no catalog updates). - all collected statistics updated in catalog. - updates access path-related info only. - updates space-related info only. - no updates (used with REPORT YES).
Appendixes
Prefetch Definitions DB2 Data Types DB2 Limits DB2 Online Manuals DB2 Reference Books
Prefetch Data Types DB2 Limits Online Manuals Reference Books
7/10/2011
<
>
MAIN MENU
EXIT
PREFETCH
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.
7/10/2011
<
>
Appendixes
EXIT
Size
2 bytes 4 bytes 4 bytes 4 bytes 8 bytes 8 bytes (m/2)+1 bytes n bytes 2 to n+2 bytes
Value Range
+ 32,767 + 2,147,483,647 5.4 x 10-79 to 7.2 x 1075 5.4 x 10-79 to 7.2 x 1075 5.4 x 10-79 to 7.2 x 1075 5.4 x 10-79 to 7.2 x 1075 1-1031 to 1031-1 max. 254 characters max. 4,046 bytes 32,704 for 32K page
COBOL Picture
PIC S9(4) COMP PIC S9(9) COMP PIC USAGE COMP 1 PIC USAGE COMP 1 PIC USAGE COMP 2 PIC USAGE COMP 2 PIC S9(m-n)V9(n) COMP 3 PIC X(n) 01 VARCHAR. 49 LTH PIC S9(4) COMP. 49 COLUMN PIC X(n). PIC G(n) DISPLAY 1 01 VARCHAR. 49 LTH PIC S9(4) 49 COLUMN PIC G(n) PIC X(10) PIC X(8) PIC X(26)
GRAPHIC(n) VARGRAPHIC(n)
<
>
Appendixes
EXIT
DB2 Limits
Stogroup name Volumes per Stogroup Database name Max no. of databases Authorization ID Partitions per tablespace (non-LARGE) (LARGE) Partition size (non-LARGE) 1- 16 parts 17 - 32 parts 33 - 64 parts Partition size (LARGE) 1 - 254 parts Segment size Tablespace size
7/10/2011
8 bytes 133 8 bytes 65,279 8 bytes 64 254 4 Gigabytes 2 Gigabytes 1 Gigabytes 4 Gigabytes 64 pages 1,016 Gigabytes > Appendixes EXIT
<
DB2 Limits
Table name View name Alias name Synonym name Column name Cursor name Host identifier No. base tables per view Max. columns per table/view Index name Columns per index Index columns size (Partitioned) (non-Partitioned) 18 bytes 18 bytes 18 bytes 18 bytes 18 bytes 18 bytes 64 bytes 15 750 18 bytes 64 40 bytes 254 bytes
7/10/2011
<
>
Appendixes
EXIT
DB2 Limits
Plan name Package name Collection name Version name DBRM name Correlation ID Max. row length Max. rows per page Max. index levels Largest SQL statement Predicates per WHERE clause Predicates per HAVING clause Concurrent users Open datasets 8 bytes 8 bytes 18 bytes 64 bytes 8 bytes 18 bytes 4056 bytes 127 or 255 comp. 6 32,765 bytes 300 300 2,000 10,000
7/10/2011
<
>
Appendixes
EXIT
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 Guide Administration Guide Command Guide Utility Guide & Reference SQL Reference Messages & Codes
7/10/2011
<
>
Appendixes
EXIT
7/10/2011
<
>
Appendixes
EXIT