SlideShare a Scribd company logo
1 of 31
Introduction to DB2
By – Aditi Agrawal
Branch – CS C
En. No. - 120198
11/4/20151
Contents
• Introduction
• Current Editions
• LUW Editions
• System Architecture
• DB2 Interface
• DB2 Objects
• Storage Groups
• Database
• Tablespace
• Table
• Data types
11/4/20152
Content(Cont.)
• Null
• Index
• Referential Integrity
• Referential Integrity - Keys
• References
11/4/20153
Introduction
What is DB2?
• Developed by IBM.
• An abbreviation for ‘IBM Database 2’.
• Introduced in June 1983.
• Support the relational model.
• Platform-specific DB2 product.
• Supports SQL.
• Latest version of DB2 is DB2 10.5.
11/4/20154
Current Editions
There are 4 products in DB2 family –
• DB2 for Linux, UNIX and Windows (informally known as DB2 LUW).
• DB2 for z/OS (mainframe).
• DB2 for i (formerly OS/400).
• DB2 for VM / VSE.
11/4/20155
LUW Editions
IBM has changed the packaging structure in the latest release of DB2
for Linux, Unix and Windows and now offers seven editions –
• Advanced Enterprise Server Edition.
• Advanced Workgroup Server Edition.
• Enterprise Server Edition.
• Workgroup Server Edition.
• Express Edition.
• Developer Edition.
• Express-C.
11/4/20156
System Architecture
Major Components of DB2 –
• SSAS (System Services Address Space)
Thread creation, Program tracing, Logging
• DBAS (Database Services Address Space)
Execution of SQLs, Database objects management, buffer
management, Data read/write, etc.
• IRLM (IMS Resource Lock Manager)
Locking
• DDF (Distributed data facility component )
Distributed Database functionality
• SPAS (Stored Procedure Address Space)
For the execution of the stored procedures
11/4/20157
DB2 Interface
11/4/20158
DB2 Objects
• DB2 manages data through a system of logical and physical
entities called objects.
• Objects that describe the data in the way, users and developers
think about it, are called logical objects.
For example - tables, and views.
• Objects that refer to the way, data is actually stored in the system,
are called physical objects.
For example - database and table space.
11/4/20159
DB2 Objects
11/4/201510
DB2 Objects Hierarchy
11/4/201511
Storage Groups
• A storage group is a named set of storage paths where data can be
stored. Storage groups are configured to represent different classes
of storage available to your database system.
CREATE STOGROUP SG
VOLUMES (V1,V2,V3);
11/4/201512
Storage Groups - (Cont.)
• The number volumes in a storage group can be changed dynamically
as shown below.
ALTER STOGROUP STOUDB6
ADD VOLUMES (V4,V5)
REMOVE VOLUMES (V1,V3);
11/4/201513
Database
• DB2 database is a set of DB2 structures that include a collection of
tables, their associated indexes, and the table spaces in which they
reside.
• One DB2 system can manage up to 65,279 databases.
11/4/201514
Creating a Database
• To create a database use
• To remove a database use
DROP DATABASE DB;
• To change the definition use
CREATE DATABASE DB
STOGROUP SG
BUFFERPOOL (BP0, BP32);
ALTER DATABASE DB
ROSHARE {OWNER, NONE}
STOGROUP SG;
11/4/201515
Tablespace
• A tablespace is a storage location where the actual data underlying
database objects can be kept.
• Three types of Tablespace
– Segmented TS (default)
– Simple TS
– Partitioned TS (for large databases)
11/4/201516
Creating a TS
• Created under an existing DB using
CREATE TABLESPACE TS
IN DB
PRIQTY 10000
SECQTY 1000
PCTFREE 10
FREEPAGE 63
LOCKSIZE ANY
BUFFERPOOL BP0
SEGSIZE 64
11/4/201517
More on TS
• To remove a tablespace use
DROP TABLESPACE TS;
• To change the definition use
ALTER TABLESPACE DB.TS
PRIQTY 200
SECQTY 200
ERASE YES
LOCKSIZE ANY
BUFFERPOOL BP1;
11/4/201518
Table
• The collection of data stored in the form of columns and rows is
known as a table.
• Create table using
CREATE TABLE EMPLOYEE
(EMP_NO SMALLINT NOT NULL,
EMP_NAME CHAR(15),
EMP_ADDRESS VARCHAR(25) NOT NULL,
PRIMARY KEY (EMP_NO));
11/4/201519
More on Table
• To remove a table
DROP TABLE EMPLOYEE;
• To change the definition
ALTER TABLE EMPLOYEE
For example, to add a new field
ALTER TABLE EMPLOYEE
ADD EMP_SALARY INTEGER;
11/4/201520
Data types
• Integer
– 4 bytes (5 if nullable)
• Small int
– 2 bytes (3 if nullable)
• Char(n)
– max. 254 bytes
• Varchar(n)
– max. 4046 bytes
• Time
– 3 bytes (4 if nullable)
• Date
– 4 bytes (5 if nullable)
11/4/201521
Data types - (Cont.)
11/4/201522
Null
• DB2 adds an extra byte to all nullable columns
• This extra byte has the information whether the field contains NULL
or not
• The NULL values do not participate while taking AVERAGE, SUM,
etc.
• Need to have special care while inserting, updating, or retrieving
nullable fields in the host language program.
11/4/201523
Index
• Is a structure used for faster retrieval of data.
• Can be unique or non-unique.
• In DB2, we need to explicitly create a unique index for the primary
key.
• Is stored in B - Tree format.
11/4/201524
Index
11/4/201525
More on Index
• Indexes are created using
CREATE [UNIQUE] INDEX IDX
ON EMPLOYEE(EMP_NO ASC);
• To remove an index
DROP INDEX IDX;
• To change the definition use
ALTER INDEX IDX;
11/4/201526
Referential Integrity
• Referential integrity is a database concept that ensures that
relationships between tables remain consistent.
• There are 3 types of keys –
Unique Key
Primary Key
Foreign Key
11/4/201527
Referential Integrity - Keys
• Unique Key
 A unique key is defined in a column (or set of columns) where
no two values are same.
 The columns of a unique key cannot contain null values.
 A table can have multiple unique keys.
 Unique keys are optional and can be defined in CREATE
TABLE or ALTER TABLE statements.
11/4/201528
Referential Integrity - Keys
• Primary Key
 A primary key is a key, which is unique in each table.
 A table cannot have more than one primary key, and the
columns of a primary key cannot contain null values.
• Foreign Key
 A foreign key is a column (or set of columns) which is a primary
key in another table.
11/4/201529
References
• http://en.wikipedia.org/wiki/IBM_DB2
• http://www-03.ibm.com/software/products/en/db2zos
• http://www-01.ibm.com/software/data/db2/linux-unix-windows/
• http://www.cs.umd.edu/class/spring2002/cmsc434-
0101/MUIseum/applications/db2.html
• http://www.webopedia.com/TERM/D/DB2.html
• http://searchdatacenter.techtarget.com/definition/DB2
11/4/201530
11/4/201531

More Related Content

What's hot

DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
imranasayed
 
Less04 database instance
Less04 database instanceLess04 database instance
Less04 database instance
Amit Bhalla
 

What's hot (20)

Vsam
VsamVsam
Vsam
 
DB2 for z/OS Architecture in Nutshell
DB2 for z/OS Architecture in NutshellDB2 for z/OS Architecture in Nutshell
DB2 for z/OS Architecture in Nutshell
 
SKILLWISE-DB2 DBA
SKILLWISE-DB2 DBASKILLWISE-DB2 DBA
SKILLWISE-DB2 DBA
 
DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
 
DB2 for z/OS Real Storage Monitoring, Control and Planning
DB2 for z/OS Real Storage Monitoring, Control and PlanningDB2 for z/OS Real Storage Monitoring, Control and Planning
DB2 for z/OS Real Storage Monitoring, Control and Planning
 
Datasets and catalogs
Datasets and catalogs Datasets and catalogs
Datasets and catalogs
 
DB2 Interview Questions - Part 1
DB2 Interview Questions - Part 1DB2 Interview Questions - Part 1
DB2 Interview Questions - Part 1
 
Skillwise JCL
Skillwise JCLSkillwise JCL
Skillwise JCL
 
DB2 utilities
DB2 utilitiesDB2 utilities
DB2 utilities
 
DB2 and storage management
DB2 and storage managementDB2 and storage management
DB2 and storage management
 
Z4R: Intro to Storage and DFSMS for z/OS
Z4R: Intro to Storage and DFSMS for z/OSZ4R: Intro to Storage and DFSMS for z/OS
Z4R: Intro to Storage and DFSMS for z/OS
 
Introduction of ISPF
Introduction of ISPFIntroduction of ISPF
Introduction of ISPF
 
online training for IBM DB2 LUW UDB DBA
online training for IBM DB2 LUW UDB DBAonline training for IBM DB2 LUW UDB DBA
online training for IBM DB2 LUW UDB DBA
 
Z OS IBM Utilities
Z OS IBM UtilitiesZ OS IBM Utilities
Z OS IBM Utilities
 
IBM DB2
IBM DB2IBM DB2
IBM DB2
 
DB2 for z/OS Bufferpool Tuning win by Divide and Conquer or Lose by Multiply ...
DB2 for z/OS Bufferpool Tuning win by Divide and Conquer or Lose by Multiply ...DB2 for z/OS Bufferpool Tuning win by Divide and Conquer or Lose by Multiply ...
DB2 for z/OS Bufferpool Tuning win by Divide and Conquer or Lose by Multiply ...
 
DB2 for z/O S Data Sharing
DB2 for z/O S  Data  SharingDB2 for z/O S  Data  Sharing
DB2 for z/O S Data Sharing
 
Less04 database instance
Less04 database instanceLess04 database instance
Less04 database instance
 
2 db2 instance creation
2 db2 instance creation2 db2 instance creation
2 db2 instance creation
 
Solving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration DilemmaSolving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration Dilemma
 

Viewers also liked

Viewers also liked (14)

Ibm db2
Ibm db2Ibm db2
Ibm db2
 
DB2 9.7 Overview
DB2 9.7 OverviewDB2 9.7 Overview
DB2 9.7 Overview
 
S3 l5 db2 - process model
S3 l5   db2 - process modelS3 l5   db2 - process model
S3 l5 db2 - process model
 
Application trends db2 day 2015 jorn
Application trends   db2 day 2015 jornApplication trends   db2 day 2015 jorn
Application trends db2 day 2015 jorn
 
IBM i: Built for Business - Philippe Bourgeois
IBM i: Built for Business - Philippe BourgeoisIBM i: Built for Business - Philippe Bourgeois
IBM i: Built for Business - Philippe Bourgeois
 
Online Training in IBM DB2 LUW/UDB DBA in Hyderabad
Online Training in IBM DB2 LUW/UDB DBA in HyderabadOnline Training in IBM DB2 LUW/UDB DBA in Hyderabad
Online Training in IBM DB2 LUW/UDB DBA in Hyderabad
 
A comparison review of DB2 9 Releases
A comparison review of DB2 9 ReleasesA comparison review of DB2 9 Releases
A comparison review of DB2 9 Releases
 
Presentation db2 connections to db2 for z os
Presentation   db2 connections to db2 for z osPresentation   db2 connections to db2 for z os
Presentation db2 connections to db2 for z os
 
Oracle Database Introduction
Oracle Database IntroductionOracle Database Introduction
Oracle Database Introduction
 
IBM InfoSphere Data Replication Products
IBM InfoSphere Data Replication ProductsIBM InfoSphere Data Replication Products
IBM InfoSphere Data Replication Products
 
Presentation db2 best practices for optimal performance
Presentation   db2 best practices for optimal performancePresentation   db2 best practices for optimal performance
Presentation db2 best practices for optimal performance
 
DB2 for z/OS and DASD-based Disaster Recovery - Blowing away the myths
DB2 for z/OS and DASD-based Disaster Recovery - Blowing away the mythsDB2 for z/OS and DASD-based Disaster Recovery - Blowing away the myths
DB2 for z/OS and DASD-based Disaster Recovery - Blowing away the myths
 
ALL ABOUT DB2 DSNZPARM
ALL ABOUT DB2 DSNZPARMALL ABOUT DB2 DSNZPARM
ALL ABOUT DB2 DSNZPARM
 
DB2 10 Universal Table Space - 2012-03-18 - no template
DB2 10 Universal Table Space - 2012-03-18 - no templateDB2 10 Universal Table Space - 2012-03-18 - no template
DB2 10 Universal Table Space - 2012-03-18 - no template
 

Similar to Ibm db2

xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptxDatabase Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptx
EliasPetros
 
DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2
Pranav Prakash
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Iftikhar70
 
Inb343 week2 sql server intro
Inb343 week2 sql server introInb343 week2 sql server intro
Inb343 week2 sql server intro
Fredlive503
 
Geek Sync | Tips for Data Warehouses and Other Very Large Databases
Geek Sync | Tips for Data Warehouses and Other Very Large DatabasesGeek Sync | Tips for Data Warehouses and Other Very Large Databases
Geek Sync | Tips for Data Warehouses and Other Very Large Databases
IDERA Software
 

Similar to Ibm db2 (20)

unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
Database Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptxDatabase Akjljljlkjlkjkljlkjldiministration.pptx
Database Akjljljlkjlkjkljlkjldiministration.pptx
 
DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2
 
Big file tablespaces
Big file tablespacesBig file tablespaces
Big file tablespaces
 
Oracle Introduction
Oracle Introduction Oracle Introduction
Oracle Introduction
 
Dbmsunit v
Dbmsunit vDbmsunit v
Dbmsunit v
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
Inb343 week2 sql server intro
Inb343 week2 sql server introInb343 week2 sql server intro
Inb343 week2 sql server intro
 
Data base.ppt
Data base.pptData base.ppt
Data base.ppt
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
MS ACCESS.pptx
MS ACCESS.pptxMS ACCESS.pptx
MS ACCESS.pptx
 
Geek Sync | Tips for Data Warehouses and Other Very Large Databases
Geek Sync | Tips for Data Warehouses and Other Very Large DatabasesGeek Sync | Tips for Data Warehouses and Other Very Large Databases
Geek Sync | Tips for Data Warehouses and Other Very Large Databases
 
Reviewing SQL Concepts
Reviewing SQL ConceptsReviewing SQL Concepts
Reviewing SQL Concepts
 
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 

Ibm db2

  • 1. Introduction to DB2 By – Aditi Agrawal Branch – CS C En. No. - 120198 11/4/20151
  • 2. Contents • Introduction • Current Editions • LUW Editions • System Architecture • DB2 Interface • DB2 Objects • Storage Groups • Database • Tablespace • Table • Data types 11/4/20152
  • 3. Content(Cont.) • Null • Index • Referential Integrity • Referential Integrity - Keys • References 11/4/20153
  • 4. Introduction What is DB2? • Developed by IBM. • An abbreviation for ‘IBM Database 2’. • Introduced in June 1983. • Support the relational model. • Platform-specific DB2 product. • Supports SQL. • Latest version of DB2 is DB2 10.5. 11/4/20154
  • 5. Current Editions There are 4 products in DB2 family – • DB2 for Linux, UNIX and Windows (informally known as DB2 LUW). • DB2 for z/OS (mainframe). • DB2 for i (formerly OS/400). • DB2 for VM / VSE. 11/4/20155
  • 6. LUW Editions IBM has changed the packaging structure in the latest release of DB2 for Linux, Unix and Windows and now offers seven editions – • Advanced Enterprise Server Edition. • Advanced Workgroup Server Edition. • Enterprise Server Edition. • Workgroup Server Edition. • Express Edition. • Developer Edition. • Express-C. 11/4/20156
  • 7. System Architecture Major Components of DB2 – • SSAS (System Services Address Space) Thread creation, Program tracing, Logging • DBAS (Database Services Address Space) Execution of SQLs, Database objects management, buffer management, Data read/write, etc. • IRLM (IMS Resource Lock Manager) Locking • DDF (Distributed data facility component ) Distributed Database functionality • SPAS (Stored Procedure Address Space) For the execution of the stored procedures 11/4/20157
  • 9. DB2 Objects • DB2 manages data through a system of logical and physical entities called objects. • Objects that describe the data in the way, users and developers think about it, are called logical objects. For example - tables, and views. • Objects that refer to the way, data is actually stored in the system, are called physical objects. For example - database and table space. 11/4/20159
  • 12. Storage Groups • A storage group is a named set of storage paths where data can be stored. Storage groups are configured to represent different classes of storage available to your database system. CREATE STOGROUP SG VOLUMES (V1,V2,V3); 11/4/201512
  • 13. Storage Groups - (Cont.) • The number volumes in a storage group can be changed dynamically as shown below. ALTER STOGROUP STOUDB6 ADD VOLUMES (V4,V5) REMOVE VOLUMES (V1,V3); 11/4/201513
  • 14. Database • DB2 database is a set of DB2 structures that include a collection of tables, their associated indexes, and the table spaces in which they reside. • One DB2 system can manage up to 65,279 databases. 11/4/201514
  • 15. Creating a Database • To create a database use • To remove a database use DROP DATABASE DB; • To change the definition use CREATE DATABASE DB STOGROUP SG BUFFERPOOL (BP0, BP32); ALTER DATABASE DB ROSHARE {OWNER, NONE} STOGROUP SG; 11/4/201515
  • 16. Tablespace • A tablespace is a storage location where the actual data underlying database objects can be kept. • Three types of Tablespace – Segmented TS (default) – Simple TS – Partitioned TS (for large databases) 11/4/201516
  • 17. Creating a TS • Created under an existing DB using CREATE TABLESPACE TS IN DB PRIQTY 10000 SECQTY 1000 PCTFREE 10 FREEPAGE 63 LOCKSIZE ANY BUFFERPOOL BP0 SEGSIZE 64 11/4/201517
  • 18. More on TS • To remove a tablespace use DROP TABLESPACE TS; • To change the definition use ALTER TABLESPACE DB.TS PRIQTY 200 SECQTY 200 ERASE YES LOCKSIZE ANY BUFFERPOOL BP1; 11/4/201518
  • 19. Table • The collection of data stored in the form of columns and rows is known as a table. • Create table using CREATE TABLE EMPLOYEE (EMP_NO SMALLINT NOT NULL, EMP_NAME CHAR(15), EMP_ADDRESS VARCHAR(25) NOT NULL, PRIMARY KEY (EMP_NO)); 11/4/201519
  • 20. More on Table • To remove a table DROP TABLE EMPLOYEE; • To change the definition ALTER TABLE EMPLOYEE For example, to add a new field ALTER TABLE EMPLOYEE ADD EMP_SALARY INTEGER; 11/4/201520
  • 21. Data types • Integer – 4 bytes (5 if nullable) • Small int – 2 bytes (3 if nullable) • Char(n) – max. 254 bytes • Varchar(n) – max. 4046 bytes • Time – 3 bytes (4 if nullable) • Date – 4 bytes (5 if nullable) 11/4/201521
  • 22. Data types - (Cont.) 11/4/201522
  • 23. Null • DB2 adds an extra byte to all nullable columns • This extra byte has the information whether the field contains NULL or not • The NULL values do not participate while taking AVERAGE, SUM, etc. • Need to have special care while inserting, updating, or retrieving nullable fields in the host language program. 11/4/201523
  • 24. Index • Is a structure used for faster retrieval of data. • Can be unique or non-unique. • In DB2, we need to explicitly create a unique index for the primary key. • Is stored in B - Tree format. 11/4/201524
  • 26. More on Index • Indexes are created using CREATE [UNIQUE] INDEX IDX ON EMPLOYEE(EMP_NO ASC); • To remove an index DROP INDEX IDX; • To change the definition use ALTER INDEX IDX; 11/4/201526
  • 27. Referential Integrity • Referential integrity is a database concept that ensures that relationships between tables remain consistent. • There are 3 types of keys – Unique Key Primary Key Foreign Key 11/4/201527
  • 28. Referential Integrity - Keys • Unique Key  A unique key is defined in a column (or set of columns) where no two values are same.  The columns of a unique key cannot contain null values.  A table can have multiple unique keys.  Unique keys are optional and can be defined in CREATE TABLE or ALTER TABLE statements. 11/4/201528
  • 29. Referential Integrity - Keys • Primary Key  A primary key is a key, which is unique in each table.  A table cannot have more than one primary key, and the columns of a primary key cannot contain null values. • Foreign Key  A foreign key is a column (or set of columns) which is a primary key in another table. 11/4/201529
  • 30. References • http://en.wikipedia.org/wiki/IBM_DB2 • http://www-03.ibm.com/software/products/en/db2zos • http://www-01.ibm.com/software/data/db2/linux-unix-windows/ • http://www.cs.umd.edu/class/spring2002/cmsc434- 0101/MUIseum/applications/db2.html • http://www.webopedia.com/TERM/D/DB2.html • http://searchdatacenter.techtarget.com/definition/DB2 11/4/201530