DB2-PPT-2-DB2 Objects V1.0

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 43

MAINFRAMES

DB2 – IBM Data Base


NAGARAJU DOMALA
DB2

“ DB2 OBJECTS“

Session 2

Nagaraju Domala
Session 2 - Objectives

On completion of this session the learner will be able to:

 Explain Physical and Logical objects


 Explain types of table spaces
 Explain difference between Alias and Synonym

Nagaraju Domala
DB2 TYPES OF OBJECTS

 STORAGE

 RECOVERY

 DATABASE

 SYSTEM

Nagaraju Domala
DB2 TYPES OF OBJECTS -
STORAGE
 STORAGE : Storage objects control where data is
physically stored and how data is moved between
storage and memory during normal operation.

 Three types of storage objects are used:


 Buffer Pools
 Containers
 Table spaces

Nagaraju Domala
DB2 TYPES OF OBJECTS -
Recovery
 RECOVERY : Recovery objects consists of
transaction log files and recovery history files.

• By default, one recovery history file and three


transaction log files are automatically created
when a database is created.

• Recovery history files are used together with


database backup images and transaction files
to coordinate data-base recovery operations.

Nagaraju Domala
DB2 TYPES OF OBJECTS -
Database
 DATABASE : known as data objects - are used
to logically store and manipulate data, as well as
control how all user data ( & some system data)
is organized).

• Data objects include tables, Indexes, views,


alias, schemas, triggers, user defined data
types, user defined functions & sequences.

Nagaraju Domala
DB2 TYPES OF OBJECTS -
System
 SYSTEM : System objects consists of registry
variables, instance configuration files and individual
database configuration files.

• Registry variables are set at the system level and


affect every instance that resides on a particular server.

• Instance configuration files are created and assigned


to individual instances during the instance creation
process.

• Database configuration files are created and assigned


to individual databases during the database creation
process.

Nagaraju Domala
DATABASE OBJECTS
(PHYSICAL & LOGICAL)

•STORAGE GROUP (Physical)


•DATABASE (Logical)
•TABLE SPACES (Physical)
SIMPLE
SEGMENTED
PARTITIONED
•TABLES (Logical)
•INDEX SPACE (Physical)
•INDEX (Logical)
•VIEWS (Logical)
•ALIAS (Logical)
•SYNONYM (Logical)

Nagaraju Domala
STORAGE
GROUP

 It is a named collection of DASD all of the same device type


within the storage group.

 Spaces and Partitions - in VSAM LDS.

 Tables - in VSAM KSDS.

Nagaraju Domala
STORAGE GROUP

 A LIST OF VOLUMES FROM WHICH DB2 IS TO ALLOCATE


SPACE

 ALL VOLUMES IN GROUP MUST BE SAME DEVICE TYPE

 USER CAN ALLOCATE SPACE VIA VSAM ACCESS METHOD


SERVICES

Nagaraju Domala
DATABASE

A collection of logically related objects

- Tables
- Table spaces
- Indexes
- Index spaces

Database is the unit of START and STOP.

It is typically not contained in a single set of disks,


but rather occupies portions of many disks.

One DB2 system can manage up to 64,000 databases.

Nagaraju Domala
TABLE SPACE

A logical address space on secondary storage


- to hold one or more tables.

As the table size increases, more memory is


acquired for the table space.

Max size of table space - 64 billion bytes.

Nagaraju Domala
TABLE SPACE
No limit to the no. of table spaces in a database.

Page size in a table space - all 4k or all 32 k bytes.

Unit for Recovery and Reorganization.

Simple Table Spaces

Table spaces Segmented Table Spaces

Partitioned Table Spaces

Nagaraju Domala
TABLE SPACE PAGE

 A TABLE SPACE IS DIVIDED INTO 4K BLOCKS CALLED PAGE


• A PAGE IS THE UNIT OF I/O TRANSMISSION
• A PAGE MAY CONTAIN ONE OR MANY ROWS (MAXIMUM
127)
• A ROW MUST LIE WITHIN ONE PAGE
(TO ACCOMMODATE ROWS LARGER
THAN 4K , PAGES CAN BE 32K)

Nagaraju Domala
Page - Diagram

Page Header Row 1 ID Sam

1441 20000 98494111

Row 2 ID

Page Footer

Nagaraju Domala
Simple Table Space

Contains more than one table ( rows) in a single page.

Advantages :

1. Rows of different tables can be clustered together to


improve access time to logically related data.
( No. of Info operations would be reduced)

2. Efficient Referential Integrity.

Nagaraju Domala
Disadvantages

1. Inefficient Recovery & Reorganization.

2. Table scan requires table space scan


- Sequential Access is very slow
- Unnecessary tables also will be read

Nagaraju Domala
Simple Table space - Diagram

Nagaraju Domala
Segmented Table
Space
Table space is divided into segments.
Segment size 4 pages to 64 pages ( Multiple of 4).
Each segment can have rows of only one table.
Segment Tables

Advantages :

1. Like single table space - can contain more than one table
2. Single page contains rows of a single table
3. Supports variable length records (rows).
4. Efficient table scan.
5. Efficient recovery, reorganization.

Nagaraju Domala
Segmented Table space - Diagram

Nagaraju Domala
Partitioned Table Space

• Occupies more than one DASD.


• For very large tables with millions of Rows.
• Contains only one table.
• Partitioned
. in accordance with value ranges of a
partitioning column / column combination.

Partition Table

Nagaraju Domala
Partitioned Table Space

Advantages :

 Some portions of Database can be quickly accessible by


using fast DASD for those partitions.
 Parts of the database can be recovered.

Disadvantages :

 Update operation on partitioning column is not allowed

Nagaraju Domala
Partitioned Table space - Diagram

PARTITION 1 PARTITION 2

PARTITION KEY A-D PARTITION KEY E-H

Nagaraju Domala
TABLE SPACE TYPES

• SIMPLE TABLE SPACE


• SEGMENTED TABLE SPACE

SIMPLE AND SEGMENTED TABLE

SPACES CAN HOLD MORE THAN

ONE TABLE

• PARTITIONED TABLE SPACE

Nagaraju Domala
PARTITIONED TABLE SPACE

• EACH PARTITION BELONGS TO A RANGE OF KEY VALUES

Nagaraju Domala
RECOMMENDATIONS

 STANDARD CHOICE
• SEGMENTED TABLE SPACE

 TO INTERLEAVE ROWS OF DIFFERENT TABLES


• SIMPLE TABLE SPACE

 FOR A VERY LARGE TABLE


• PARTITIONED TABLE SPACE

Nagaraju Domala
CREATE TABLESPACE

CREATE TABLE TS3 IN DB3


SEGSIZE 4 ----------------------------------------------
-NUMBER OF PAGES PER SEGMENT

NUMPARTS 3
NOT BOTH
- NUMBER OF PARTITIONS -------------------

Nagaraju Domala
CREATE TABLESPACE

BUFFERPOOL BPO
DETERMINES PAGE SIZE
USING STOGROUP SG1

PRE-DEFINED LIST OF
STORAGE GROUP VOLUMES

PRIQTY 52 SECQTY 20
PRIMARY/SECONDARY AMOUNTS,
IN KB

Nagaraju Domala
CREATE TABLESPACE

PCTFREE 10 FREESPACE 4 SPACE


LEFT BY LOAD/REORG FOR LATER

LOCKSIZE ANY AMOUNT OF TABLE LOCKED


DURING USE

Nagaraju Domala
LOCKSIZE PAGE

IN
USE

AVAILABLE

 BETTER DATA CONCURRENCY

Nagaraju Domala
LOCKSIZE ANY

 DB2 TO CHOOSE BEST LOCK SIZE

 SYSTEM STARTS WITH PAGE

 IF PAGE LOCKS BECOME EXCESSIVE , DB2


DYNAMICALLY UPGRADES TO TABLESPACE ,
OR TO TABLE IF SEGMENT

Nagaraju Domala
Buffer Pool

 These are areas of virtual storage that DB2 uses to


store data temporarily.

Nagaraju Domala
TABLES

Stored record : prefix ( control info )


+ all the stored fields.

Stored field : prefix ( if varying length filed)


+ Null indicator prefix
+ Actual Data-value

Nagaraju Domala
TABLES

Internally, stored records are addressed by ‘Record ID’ or RID.

RID’s are unique within the containing table space.

RID of Row R consists of 2 parts

Page number of page P containing R

Byte offset of R from the bottom of P

Nagaraju Domala
TABLES

1. EDITPROC - will be given control every time a


record (row) is stored or fetched.

2. FIELDPROC - will be given control every time a field is


accessed.

3. VALIDPROC - will be given control every time a row


of that table is inserted, updated or deleted.

Max. of 1 VALIDPROC per table.

Nagaraju Domala
INDEX SPACE

1. An index space contains only one Index.

2. It is created automatically wherever a table is created with


an index.

3. Can be reorganized, recovered independently.

4. Index space for a partitioned table space is also Partitioned.

INDEX
Contains the RID of the rows in table in an order

Nagaraju Domala
VIEWS

• A view is an alternative way of describing data that exists


in one or more tables.

• It does not contain data but, instead, is a stored set of SQL


commands that define a sub-set of rows and columns in the
base table.

• Views can provide customized tables for specific users

• Views can be utilized to limit access to certain kinds of data.

Nagaraju Domala
Alias & Synonyms

• ALIAS - Mean ‘another name’ for the table.

• Aliases are used basically for accessing remote tables


(in distributed data processing).

• SYNONYM- Also means another name for the table, but


is private to the user who created it.

Nagaraju Domala
INDEX

•An index is an ordered list of the key values of a column or


columns of a table.

• Similar to table Space, each index resides on an index


Space.

• Index Space is automatically created when the index is


created.

Nagaraju Domala
CREATE DATABASE

 DEFINE A DATABASE TO ENCOMPASS THE DATA

CREATE DATABASE DB3

DB3

Nagaraju Domala
CREATE TABLE SPACE

 ALLOCATE SPACE TO HOLD THE TABLES

CREATE TABLESPACE TS3 IN DB3

TS1 TS2 TS3


DB3

Nagaraju Domala
CREATE TABLE

 DESCRIBE THE TABLES

CREATE TABLE EMP ... IN DB3.TS2

EMP

TS2 TS3
TS1
DB3

Nagaraju Domala

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy