SlideShare a Scribd company logo
1 of 100
DB2 for OS/390 Fundamentals
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],DB2 for OS/390 Fundamentals
Introduction to DB2 Universal Database
Introduction to DB2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A brief DB2 History 1983 DB2 v1 ships 1993 DB2 for OS/2 and Aix 1994 DB2 for MVS v4 introduces Data Sharing 1996 DB2 UDB - multimedia, web-ready, cross-platform (non-mainframe) 1999 DB2 UDB for OS/390 (v6.1) 2001 DB2 UDB for OS/390 and z/OS (v7.1) 2004 DB2 UDB for z/OS (v8.1) 2004 DB2 UDB for LUW (v8.2)
The Guts of DB2 Directory Catalog Tables Logs BSDS DB2 User Thread EDM Pool Sort Pool Buffer Pools RID Pool Temporary Database Working Storage Program Logic
The Guts of DB2 Address Space Name Functions DBAS Database Services Address Space SSAS System Services Address Space IRLM Intersystem Resource Lock Manager DDF Distributed Data Facility SPAS Stored Procedure Address Space(s)
Threads DB2 CICS Programs DB2 Utilities TSO Online Programs TSO Batch Programs QMF/DB2I (SPUFI) thread threads thread thread thread Distributed Programs thread
Attachment Facilities DB2 TSO Address Space DSN Processor ISPF DB2I SPUFI QMF Rexx
Data Sharing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Parallelism ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL SQL DCL DDL DML GRANT REVOKE CREATE ALTER DROP SELECT UPDATE INSERT DELETE
Results Sets DB2 Request sent to database Multiple rows returned as a results set
Authorities SYSADM Systems Administrator Can do anything to everything DBADM Database Administrator Can do anything to a database User-based Select, Update, Insert, Delete access on permissions tables; Execute, Bind access on packages; utilities/operations upon objects. SYSMAINT/SYSCTRL Other administrative DBMAINT/DBCTRL functions in DB2 }{
DB2 Objects STOGROUP DATABASE TABLESPACE TABLE VIEW INDEX ALIAS SYNONYM COLUMN
DB2’s VSAM data sets M enu  O ptions  V iew  U tilities  C ompilers  H elp  ----------------------------------------------------------------------------- DSLIST - Data Sets Matching FIGDB2.DSNDBC.DFIGE0H.*ABORT*  Row 1 of 6 Command ===>  Scroll ===>  CSR  Command - Enter "/" to select action  Tracks %Used XT  Device ----------------------------------------------------------------------------- FIGDB2.DSNDBC.DFIGE0H.SABORT.I0001.A001  FIGDB2.DSNDBD.DFIGE0H.SABORT.I0001.A001  1950  ?  31  3390 FIGDB2.DSNDBC.DFIGE0H.XABORT0.I0001.A001  FIGDB2.DSNDBD.DFIGE0H.XABORT0.I0001.A001  120  ?  6  3390 FIGDB2.DSNDBC.DFIGE0H.IABORT1.I0001.A001  FIGDB2.DSNDBD.DFIGE0H.IABORT1.I0001.A001  16  ?  15  3390 *************************** End of Data Set list **************************** Partition number  Tablespace/Index name Database name High-level qualifier
Tablespaces ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tables Rows Columns
Columns ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Data types SMALLINT/INTEGER CHARACTER/VARCHAR GRAPHIC/VARGRAPHIC/DBCLOB CHARACTER LARGE OBJECT/CLOB BINARY LARGE OBJECT/BLOB DECIMAL/NUMERIC FLOAT/REAL/DOUBLE DATE TIME TIMESTAMP ROWID
User-Defined Data types The user-defined DISTINCT TYPE is based on one of the previous basic data types. E.g. CREATE DISTINCT TYPE AUDIO AS BLOB (1M); CREATE DISTINCT TYPE VIDEO AS BLOB (1M); Then, your CREATE TABLE statement might look like this: CREATE TABLE VIDEO_CATALOG (VIDEO_NUMBER CHAR(6) NOT NULL, VIDEO_SOUND  AUDIO, VIDEO_PICS  VIDEO, ROW_ID  ROWID NOT NULL GENERATED ALWAYS);
Functions ,[object Object],[object Object],[object Object]
Routines ,[object Object],[object Object],[object Object],[object Object],[object Object]
Stored Procedures Calling Program MVS Schedule SP SELECT INSERT UPDATE DELETE DB2 Start Proc SELECT INSERT UPDATE DELETE End Proc SPAS Call Results
Other features ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Check Constraints Data value restrictions on the contents of a column. EXTN CHAR(4) CONSTRAINT NUMBER CHECK (EXTN BETWEEN ‘0000’ AND ‘9999’) CONSTRAINT BYPASS CHECK(BYPASS IN ('Y', 'N')  AND (BYPASS = 'N' OR  (BYPASS = 'Y’ AND   REASON IS NOT NULL)))
Triggers CREATE TRIGGER UPD_SALARY BEFORE UPDATE OF SALARY ON EMP  FOR EACH ROW MODE DB2SQL WHEN (NEW.SALARY>(OLD.SALARY*1.5)) BEGIN ATOMIC SIGNAL SQLSTATE ‘75001’ (‘Raise exceeds 50%’); END; CREATE TRIGGER RISK.GRT_DEL AFTER DELETE ON RISK.GENERIC  FOR EACH ROW MODE DB2SQL BEGIN ATOMIC INSERT INTO RISK.AUDIT_TRAIL (TABLE_NAME, ACTION, GRT,    GRTNAME, GRTDESC) VALUES ('GENERIC','D', OLD.GRT,   OLD.GRTNAME, OLD.GRTDESC); END;
Relational Theory ,[object Object],[object Object],[object Object],[object Object]
Referential Integrity EMP EMPNO FIRSTNAME MIDINIT LASTNAME WORKDEPT PHONENO HIREDATE JOB SEX BIRTHDATE SALARY BONUS DEPT DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION
Indexes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Indexes INDEXSPACE TABLESPACE TABLE DEPT INDEX on DEPTNO A00 B01 C01 D01
DB2 Commands and Utilities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Some DB2 Utilities ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Some DB2 Commands ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
TSO DB2 Commands ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sample Database
Sample Database 1 2 3 4 5 6 7 8 9 10 11 DEPT EMP PROJ EMPPROJACT EMP_ PHOTO_ RESUME ACT PROJACT
Sample Database ACTNO  ACTKWD  ACTDESC ACT DEPT DEPTNO  DEPTNAME MGRNO  ADMRDEPT LOCATION EMP EMPNO  FIRSTNME  MIDINIT  LASTNAME  WORKDEPT  PHONENO  HIREDATE  JOB  EDLEVEL  SEX  BIRTHDATE SALARY  BONUS  COMM  EMP_ PHOTO_ RESUME EMPNO  EMP_ROWID  PSEG_PHOTO BMP_PHOTO  RESUME  EMPPROJACT EMPNO  PROJNO  ACTNO  EMPTIME  EMSTDATE EMENDATE PROJACT PROJNO  ACTNO  ACSTAFF  ACSTDATE ACENDATE PROJ PROJNO  PROJNAME DEPTNO  RESPEMP  PRSTAFF  PRSTDATE PRENDATE MAJPROJ
Sample Database ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sample Database ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sample Database ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Joy of SQL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Joy of SELECTs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object],[object Object]
Advanced SQL
Advanced SQL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Column Functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Scalar Functions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Special Registers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Joins ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Inner Join SELECT EMPNO,LASTNAME, WORKDEPT FROM  EMP WHERE  WORKDEPT LIKE ‘D%'; SELECT DEPTNO,DEPTNAME FROM  DEPT WHERE  DEPTNO LIKE 'D%'
Inner Join SELECT EMPNO, LASTNAME, WORKDEPT DEPTNAME FROM  EMP JOIN  DEPT ON  WORKDEPT = DEPTNO WHERE  DEPTNO LIKE 'D%' ;
Outer Join SELECT EMPNO, LASTNAME, WORKDEPT DEPTNAME FROM  EMP RIGHT OUTER JOIN DEPT ON  WORKDEPT = DEPTNO WHERE  DEPTNO LIKE 'D%' ;
Unions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Subqueries ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Nested Table Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sorting ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Aggregation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Relational Division ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CASE Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Date and Time Arithmetic ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Global Temporary Tables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Existence ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Embedded SQL
Embedded SQL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Static Program Preparation DB2 Catalog DB2 Directory Source Program DCLGEN Precompiler Modified Source DBRM Bind Compile Link edit Package Plan Load Module
Collections in HUON Source Program DBRM Load Module Bind Package in FIGE1 collection FIGE1 tables Package in FIGE2 collection FIGE2 tables Package in FIGE3 collection FIGE3 tables Bind Bind
Host variables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Programming with cursors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Programming with cursors DECLARE C1 CURSOR FOR SELECT DEPTNO, DEPTNAME FROM DEPT  WHERE ADMRDEPT = :ADMRDEPT
Programming with cursors OPEN C1 Results Set
Programming with cursors First fetch... FETCH C1 INTO  :DEPTNO, :DEPTNAME Results Set
Programming with cursors Next one… FETCH C1 INTO  :DEPTNO, :DEPTNAME Results Set
Programming with cursors And again… FETCH C1 INTO  :DEPTNO, :DEPTNAME Results Set
Programming with cursors And again… FETCH C1 INTO  :DEPTNO, :DEPTNAME Results Set
Programming with cursors …and so on until the last line of the results set… …the next FETCH returns an SQLCODE of +100, with no rows returned. Host variables may or may not contain valid data at this point, so ALWAYS check your SQLCODE before processing your data! Results Set . . .
Programming with cursors Always clean up your cursors! Data processing is finalised, the cursor is closed and all your results set storage is cleared up once you issue the CLOSE C1 statement, after your FETCH processing gets the +100 SQLCODE signifying the end of the results set.
Programming with cursors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Programming with cursors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],More Programming Tips
Performance: The Black Arts
Performance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Performance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Commitment ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Unit of Work time Program begins Update Insert Delete COMMIT Log
Unit of Work time Error! Program begins Update Insert Delete ROLLBACK
Locking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Concurrency Page Lock Matrix
Isolation Levels ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example ,[object Object],[object Object],[object Object],[object Object]
SQL Performance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Best Coding Practice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Performance Tools ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
EXPLAIN EXPLAIN ALL SET QUERY=1 FOR SELECT FIRSTNME, MIDINIT,   LASTNAME FROM EMP WHERE EMPNO=‘000240’; Access Paths UDF Resolution Cost Estimates Explain Plan, Package or SQL statement DB2 Optimizer PLAN_TABLE DSN_STATEMENT_TABLE DSN_FUNCTION_TABLE
Tools of the trade
Tools ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tools ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],DB2 for OS/390 Fundamentals
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],DB2 for OS/390 Fundamentals

More Related Content

What's hot

What's hot (20)

Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Introduction to SQL (for Chicago Booth MBA technology club)
Introduction to SQL (for Chicago Booth MBA technology club)Introduction to SQL (for Chicago Booth MBA technology club)
Introduction to SQL (for Chicago Booth MBA technology club)
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
DataBase Management System Lab File
DataBase Management System Lab FileDataBase Management System Lab File
DataBase Management System Lab File
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Partitioning on Oracle 12c - What changed on the most important Oracle feature
Partitioning on Oracle 12c - What changed on the most important Oracle featurePartitioning on Oracle 12c - What changed on the most important Oracle feature
Partitioning on Oracle 12c - What changed on the most important Oracle feature
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012
 
Assignment#07
Assignment#07Assignment#07
Assignment#07
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Create table
Create tableCreate table
Create table
 
Sql queries
Sql queriesSql queries
Sql queries
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Oracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guideOracle Sql & PLSQL Complete guide
Oracle Sql & PLSQL Complete guide
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Les11 Including Constraints
Les11 Including ConstraintsLes11 Including Constraints
Les11 Including Constraints
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 

Viewers also liked

Moda perakendesinde iş modeli seçimi ima - burak günbal - 15-10-11
Moda perakendesinde iş modeli seçimi   ima - burak günbal - 15-10-11Moda perakendesinde iş modeli seçimi   ima - burak günbal - 15-10-11
Moda perakendesinde iş modeli seçimi ima - burak günbal - 15-10-11Burak Günbal
 
Waisman Center, 08.18.10
Waisman Center, 08.18.10Waisman Center, 08.18.10
Waisman Center, 08.18.10JacquiSakowski
 
Coherence - Pitch SV
Coherence - Pitch SVCoherence - Pitch SV
Coherence - Pitch SVJakub Bares
 
Seminario PresentacióN
Seminario PresentacióNSeminario PresentacióN
Seminario PresentacióNEllen Sanz
 
Social Media Brian Johnson Program, 07.14.10
Social Media Brian Johnson Program, 07.14.10Social Media Brian Johnson Program, 07.14.10
Social Media Brian Johnson Program, 07.14.10JacquiSakowski
 
RTL101: Perakende Sistemlerine Giriş
RTL101: Perakende Sistemlerine GirişRTL101: Perakende Sistemlerine Giriş
RTL101: Perakende Sistemlerine GirişBurak Günbal
 
Meals of the_world
Meals of the_worldMeals of the_world
Meals of the_worldEllen Sanz
 
Moda Perakendesi Yönetimi Eğitimi İçerik Sunumu
Moda Perakendesi Yönetimi Eğitimi İçerik SunumuModa Perakendesi Yönetimi Eğitimi İçerik Sunumu
Moda Perakendesi Yönetimi Eğitimi İçerik SunumuBurak Günbal
 
Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu) ima- burak günbal - 0...
Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu)   ima- burak günbal - 0...Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu)   ima- burak günbal - 0...
Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu) ima- burak günbal - 0...Burak Günbal
 
CHRISTMAS VOCABULARY
CHRISTMAS VOCABULARYCHRISTMAS VOCABULARY
CHRISTMAS VOCABULARYEllen Sanz
 
Models of Strategic Thinking
Models of Strategic ThinkingModels of Strategic Thinking
Models of Strategic ThinkingBurak Günbal
 

Viewers also liked (13)

Moda perakendesinde iş modeli seçimi ima - burak günbal - 15-10-11
Moda perakendesinde iş modeli seçimi   ima - burak günbal - 15-10-11Moda perakendesinde iş modeli seçimi   ima - burak günbal - 15-10-11
Moda perakendesinde iş modeli seçimi ima - burak günbal - 15-10-11
 
Waisman Center, 08.18.10
Waisman Center, 08.18.10Waisman Center, 08.18.10
Waisman Center, 08.18.10
 
Coherence - Pitch SV
Coherence - Pitch SVCoherence - Pitch SV
Coherence - Pitch SV
 
Seminario PresentacióN
Seminario PresentacióNSeminario PresentacióN
Seminario PresentacióN
 
Tainted LOB
Tainted LOBTainted LOB
Tainted LOB
 
Social Media Brian Johnson Program, 07.14.10
Social Media Brian Johnson Program, 07.14.10Social Media Brian Johnson Program, 07.14.10
Social Media Brian Johnson Program, 07.14.10
 
RTL101: Perakende Sistemlerine Giriş
RTL101: Perakende Sistemlerine GirişRTL101: Perakende Sistemlerine Giriş
RTL101: Perakende Sistemlerine Giriş
 
Meals of the_world
Meals of the_worldMeals of the_world
Meals of the_world
 
Moda Perakendesi Yönetimi Eğitimi İçerik Sunumu
Moda Perakendesi Yönetimi Eğitimi İçerik SunumuModa Perakendesi Yönetimi Eğitimi İçerik Sunumu
Moda Perakendesi Yönetimi Eğitimi İçerik Sunumu
 
Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu) ima- burak günbal - 0...
Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu)   ima- burak günbal - 0...Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu)   ima- burak günbal - 0...
Perakende nedir? Perakendeci kimdir? (Tanisma Sunumu) ima- burak günbal - 0...
 
CHRISTMAS VOCABULARY
CHRISTMAS VOCABULARYCHRISTMAS VOCABULARY
CHRISTMAS VOCABULARY
 
Models of Strategic Thinking
Models of Strategic ThinkingModels of Strategic Thinking
Models of Strategic Thinking
 
Zara: Fast Fashion
Zara: Fast FashionZara: Fast Fashion
Zara: Fast Fashion
 

Similar to MDI Training DB2 Course

Database Foundation Training
Database Foundation TrainingDatabase Foundation Training
Database Foundation TrainingFranky Lao
 
Getting Started with SQL Language.pptx
Getting Started with SQL Language.pptxGetting Started with SQL Language.pptx
Getting Started with SQL Language.pptxCecilia Brusatori
 
Module 02 teradata basics
Module 02 teradata basicsModule 02 teradata basics
Module 02 teradata basicsMd. Noor Alam
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Serban Tanasa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Odtug2011 adf developers make the database work for you
Odtug2011 adf developers make the database work for youOdtug2011 adf developers make the database work for you
Odtug2011 adf developers make the database work for youLuc Bors
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1MariaDB plc
 
What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?ukdpe
 
SQL Server 2008 Overview
SQL Server 2008 OverviewSQL Server 2008 Overview
SQL Server 2008 OverviewEric Nelson
 
Mainframe Technology Overview
Mainframe Technology OverviewMainframe Technology Overview
Mainframe Technology OverviewHaim Ben Zagmi
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresSteven Johnson
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 

Similar to MDI Training DB2 Course (20)

Database Foundation Training
Database Foundation TrainingDatabase Foundation Training
Database Foundation Training
 
Module02
Module02Module02
Module02
 
Getting Started with SQL Language.pptx
Getting Started with SQL Language.pptxGetting Started with SQL Language.pptx
Getting Started with SQL Language.pptx
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
 
Module 02 teradata basics
Module 02 teradata basicsModule 02 teradata basics
Module 02 teradata basics
 
lovely
lovelylovely
lovely
 
ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Odtug2011 adf developers make the database work for you
Odtug2011 adf developers make the database work for youOdtug2011 adf developers make the database work for you
Odtug2011 adf developers make the database work for you
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
Die Neuheiten in MariaDB 10.2 und MaxScale 2.1
 
What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?What's New for Developers in SQL Server 2008?
What's New for Developers in SQL Server 2008?
 
SQL Server 2008 Overview
SQL Server 2008 OverviewSQL Server 2008 Overview
SQL Server 2008 Overview
 
Mainframe Technology Overview
Mainframe Technology OverviewMainframe Technology Overview
Mainframe Technology Overview
 
Oracle 10g
Oracle 10gOracle 10g
Oracle 10g
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 

MDI Training DB2 Course

  • 1. DB2 for OS/390 Fundamentals
  • 2.
  • 3. Introduction to DB2 Universal Database
  • 4.
  • 5. A brief DB2 History 1983 DB2 v1 ships 1993 DB2 for OS/2 and Aix 1994 DB2 for MVS v4 introduces Data Sharing 1996 DB2 UDB - multimedia, web-ready, cross-platform (non-mainframe) 1999 DB2 UDB for OS/390 (v6.1) 2001 DB2 UDB for OS/390 and z/OS (v7.1) 2004 DB2 UDB for z/OS (v8.1) 2004 DB2 UDB for LUW (v8.2)
  • 6. The Guts of DB2 Directory Catalog Tables Logs BSDS DB2 User Thread EDM Pool Sort Pool Buffer Pools RID Pool Temporary Database Working Storage Program Logic
  • 7. The Guts of DB2 Address Space Name Functions DBAS Database Services Address Space SSAS System Services Address Space IRLM Intersystem Resource Lock Manager DDF Distributed Data Facility SPAS Stored Procedure Address Space(s)
  • 8. Threads DB2 CICS Programs DB2 Utilities TSO Online Programs TSO Batch Programs QMF/DB2I (SPUFI) thread threads thread thread thread Distributed Programs thread
  • 9. Attachment Facilities DB2 TSO Address Space DSN Processor ISPF DB2I SPUFI QMF Rexx
  • 10.
  • 11.
  • 12. SQL SQL DCL DDL DML GRANT REVOKE CREATE ALTER DROP SELECT UPDATE INSERT DELETE
  • 13. Results Sets DB2 Request sent to database Multiple rows returned as a results set
  • 14. Authorities SYSADM Systems Administrator Can do anything to everything DBADM Database Administrator Can do anything to a database User-based Select, Update, Insert, Delete access on permissions tables; Execute, Bind access on packages; utilities/operations upon objects. SYSMAINT/SYSCTRL Other administrative DBMAINT/DBCTRL functions in DB2 }{
  • 15. DB2 Objects STOGROUP DATABASE TABLESPACE TABLE VIEW INDEX ALIAS SYNONYM COLUMN
  • 16. DB2’s VSAM data sets M enu O ptions V iew U tilities C ompilers H elp ----------------------------------------------------------------------------- DSLIST - Data Sets Matching FIGDB2.DSNDBC.DFIGE0H.*ABORT* Row 1 of 6 Command ===> Scroll ===> CSR Command - Enter "/" to select action Tracks %Used XT Device ----------------------------------------------------------------------------- FIGDB2.DSNDBC.DFIGE0H.SABORT.I0001.A001 FIGDB2.DSNDBD.DFIGE0H.SABORT.I0001.A001 1950 ? 31 3390 FIGDB2.DSNDBC.DFIGE0H.XABORT0.I0001.A001 FIGDB2.DSNDBD.DFIGE0H.XABORT0.I0001.A001 120 ? 6 3390 FIGDB2.DSNDBC.DFIGE0H.IABORT1.I0001.A001 FIGDB2.DSNDBD.DFIGE0H.IABORT1.I0001.A001 16 ? 15 3390 *************************** End of Data Set list **************************** Partition number Tablespace/Index name Database name High-level qualifier
  • 17.
  • 19.
  • 20. Data types SMALLINT/INTEGER CHARACTER/VARCHAR GRAPHIC/VARGRAPHIC/DBCLOB CHARACTER LARGE OBJECT/CLOB BINARY LARGE OBJECT/BLOB DECIMAL/NUMERIC FLOAT/REAL/DOUBLE DATE TIME TIMESTAMP ROWID
  • 21. User-Defined Data types The user-defined DISTINCT TYPE is based on one of the previous basic data types. E.g. CREATE DISTINCT TYPE AUDIO AS BLOB (1M); CREATE DISTINCT TYPE VIDEO AS BLOB (1M); Then, your CREATE TABLE statement might look like this: CREATE TABLE VIDEO_CATALOG (VIDEO_NUMBER CHAR(6) NOT NULL, VIDEO_SOUND AUDIO, VIDEO_PICS VIDEO, ROW_ID ROWID NOT NULL GENERATED ALWAYS);
  • 22.
  • 23.
  • 24. Stored Procedures Calling Program MVS Schedule SP SELECT INSERT UPDATE DELETE DB2 Start Proc SELECT INSERT UPDATE DELETE End Proc SPAS Call Results
  • 25.
  • 26. Check Constraints Data value restrictions on the contents of a column. EXTN CHAR(4) CONSTRAINT NUMBER CHECK (EXTN BETWEEN ‘0000’ AND ‘9999’) CONSTRAINT BYPASS CHECK(BYPASS IN ('Y', 'N') AND (BYPASS = 'N' OR (BYPASS = 'Y’ AND REASON IS NOT NULL)))
  • 27. Triggers CREATE TRIGGER UPD_SALARY BEFORE UPDATE OF SALARY ON EMP FOR EACH ROW MODE DB2SQL WHEN (NEW.SALARY>(OLD.SALARY*1.5)) BEGIN ATOMIC SIGNAL SQLSTATE ‘75001’ (‘Raise exceeds 50%’); END; CREATE TRIGGER RISK.GRT_DEL AFTER DELETE ON RISK.GENERIC FOR EACH ROW MODE DB2SQL BEGIN ATOMIC INSERT INTO RISK.AUDIT_TRAIL (TABLE_NAME, ACTION, GRT, GRTNAME, GRTDESC) VALUES ('GENERIC','D', OLD.GRT, OLD.GRTNAME, OLD.GRTDESC); END;
  • 28.
  • 29. Referential Integrity EMP EMPNO FIRSTNAME MIDINIT LASTNAME WORKDEPT PHONENO HIREDATE JOB SEX BIRTHDATE SALARY BONUS DEPT DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION
  • 30.
  • 31. Indexes INDEXSPACE TABLESPACE TABLE DEPT INDEX on DEPTNO A00 B01 C01 D01
  • 32.
  • 33.
  • 34.
  • 35.
  • 37. Sample Database 1 2 3 4 5 6 7 8 9 10 11 DEPT EMP PROJ EMPPROJACT EMP_ PHOTO_ RESUME ACT PROJACT
  • 38. Sample Database ACTNO ACTKWD ACTDESC ACT DEPT DEPTNO DEPTNAME MGRNO ADMRDEPT LOCATION EMP EMPNO FIRSTNME MIDINIT LASTNAME WORKDEPT PHONENO HIREDATE JOB EDLEVEL SEX BIRTHDATE SALARY BONUS COMM EMP_ PHOTO_ RESUME EMPNO EMP_ROWID PSEG_PHOTO BMP_PHOTO RESUME EMPPROJACT EMPNO PROJNO ACTNO EMPTIME EMSTDATE EMENDATE PROJACT PROJNO ACTNO ACSTAFF ACSTDATE ACENDATE PROJ PROJNO PROJNAME DEPTNO RESPEMP PRSTAFF PRSTDATE PRENDATE MAJPROJ
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51. Inner Join SELECT EMPNO,LASTNAME, WORKDEPT FROM EMP WHERE WORKDEPT LIKE ‘D%'; SELECT DEPTNO,DEPTNAME FROM DEPT WHERE DEPTNO LIKE 'D%'
  • 52. Inner Join SELECT EMPNO, LASTNAME, WORKDEPT DEPTNAME FROM EMP JOIN DEPT ON WORKDEPT = DEPTNO WHERE DEPTNO LIKE 'D%' ;
  • 53. Outer Join SELECT EMPNO, LASTNAME, WORKDEPT DEPTNAME FROM EMP RIGHT OUTER JOIN DEPT ON WORKDEPT = DEPTNO WHERE DEPTNO LIKE 'D%' ;
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 66.
  • 67. Static Program Preparation DB2 Catalog DB2 Directory Source Program DCLGEN Precompiler Modified Source DBRM Bind Compile Link edit Package Plan Load Module
  • 68. Collections in HUON Source Program DBRM Load Module Bind Package in FIGE1 collection FIGE1 tables Package in FIGE2 collection FIGE2 tables Package in FIGE3 collection FIGE3 tables Bind Bind
  • 69.
  • 70.
  • 71. Programming with cursors DECLARE C1 CURSOR FOR SELECT DEPTNO, DEPTNAME FROM DEPT WHERE ADMRDEPT = :ADMRDEPT
  • 72. Programming with cursors OPEN C1 Results Set
  • 73. Programming with cursors First fetch... FETCH C1 INTO :DEPTNO, :DEPTNAME Results Set
  • 74. Programming with cursors Next one… FETCH C1 INTO :DEPTNO, :DEPTNAME Results Set
  • 75. Programming with cursors And again… FETCH C1 INTO :DEPTNO, :DEPTNAME Results Set
  • 76. Programming with cursors And again… FETCH C1 INTO :DEPTNO, :DEPTNAME Results Set
  • 77. Programming with cursors …and so on until the last line of the results set… …the next FETCH returns an SQLCODE of +100, with no rows returned. Host variables may or may not contain valid data at this point, so ALWAYS check your SQLCODE before processing your data! Results Set . . .
  • 78. Programming with cursors Always clean up your cursors! Data processing is finalised, the cursor is closed and all your results set storage is cleared up once you issue the CLOSE C1 statement, after your FETCH processing gets the +100 SQLCODE signifying the end of the results set.
  • 79.
  • 80.
  • 81.
  • 83.
  • 84.
  • 85.
  • 86. Unit of Work time Program begins Update Insert Delete COMMIT Log
  • 87. Unit of Work time Error! Program begins Update Insert Delete ROLLBACK
  • 88.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95. EXPLAIN EXPLAIN ALL SET QUERY=1 FOR SELECT FIRSTNME, MIDINIT, LASTNAME FROM EMP WHERE EMPNO=‘000240’; Access Paths UDF Resolution Cost Estimates Explain Plan, Package or SQL statement DB2 Optimizer PLAN_TABLE DSN_STATEMENT_TABLE DSN_FUNCTION_TABLE
  • 96. Tools of the trade
  • 97.
  • 98.
  • 99.
  • 100.