Sei sulla pagina 1di 31

DBA Training

Schedule
◆ Day 1:
◆ FirstSession : DB2 Objects
◆ Second Session : Program Preparation

◆ Day 2:
◆ First
Session: Utilities
◆ Second Session:
◆ Day 3: DBA Case study
◆ Day 4 : DBA Case study completion
Topics Covered
◆ DB2 Objects
◆ Program preparation & effective SQL
coding
◆ Performance Issues
◆ Utilities: Data and Application
Recovery and Backup
◆ DB2 Security
Day 1:
◆ DB2 Objects
◆ Program preparation
◆ Effective SQL coding
Overview of DB2 Objects
◆ System Structures
◆ DB2 catalog (DSNDB06)
◆ DB2 directory (DSNDB01)
◆ Active and Archive Logs
◆ Bootstrap Dataset BSDS
◆ Buffer pools
◆ Communication Database
◆ DDCS
◆ RLF database
Overview of DB2 Objects
◆ Db2 data structures
◆ Databases
◆ Storage Groups
◆ Tablespaces
◆ Tables
◆ Indexes
◆ Views
DB2 physical organization
DB2 Tablespaces

Logical Representation
Physical
Representation
DB2 Transformation
Pages
SPACE
• A Page is either 4K or 32K

◆ A Page is the unit of I/O

PAGE ◆ A Page can contain a


maximum of 127 data
HEADER
records.

FOOTER
◆ A data record does not
span pages
Data Records
Simple Tablespaces

Table 1 - Row X Table 2 - Row C

Table 1 - Row Y Table 3 - Row N

Table 2 - Row A Table 2 - Row D

Table 2 - Row B Table 1 - Row W

Table 1 - Row Z Table 2 - Row E

Table 3 - Row M Table 3 - Row O


PAGE 1 PAGE 2
Segmented Tablespaces
Segment 1 Segment 2 Segment 3

Table 1 Table 2 Table 1


Partitioned Tablespaces
Part 1 Part 2 Part 3 Part 4
Indexes
Table
Index 101

101 1 104
102 3 102
103 4 103
104 2

KEY Position
Indexes : Terminology

Indexing Key Composite Key

Unique Index Non-Unique Index

Primary Index Secondary Index

Partitioning Index Clustering Index


B+Trees

Root Node

*2 5 *
Intermediate Nodes
*8 *1 7 * *3 3 *4 0 *

*1 *3 *8 *9 *1 1 *1 7 *1 9 *2 1 *2 5 *2 8 *3 1 *3 3 *3 5 *3 8 *4 0 *4 6 *5 1 *5 5

Leaf Nodes
Pointing to
Data Pages
Clustering Index

*2 5 *

*8 *1 7 * *3 3 *4 0 *

*1 *3 *8 *9 *1 1 *1 7 *1 9 *2 1 *2 5 *2 8 *3 1 *3 3 *3 5 *3 8 *4 0 *4 6 *5 1 *5 5

Data
Pages
Non-Clustered Index Scan

*2 5 *

*8 *1 7 * *3 3 *4 0 *

*1 *3 *8 *9 *1 1 *1 7 *1 9 *2 1 *2 5 *2 8 *3 1 *3 3 *3 5 *3 8 *4 0 *4 6 *5 1 *5 5

Data
Pages
Stogroup
SG2
SG1

DEV001 DEV002

DEV003 DEV004

SG3
Database
Tablespace

Table Table

Tablespace

Table

Index

Index
Storage Groups
Bufferpools

4 KB Pages 32KB Pages


DDL - CREATE Storage Group

◆ Syntax:
CREATE STOGROUP stogroup-name
VOLUMES (vol1, vol2, ...)
VCAT catalog-name
[PASSWORD password]
CREATE STOGROUP TRG1T01
VOLUMES (DBPK01, DBPK02)
VCAT DBZ2TRG
DDL - ALTER Storage Group

◆ Syntax:
ALTER STOGROUP stogroup-name
ADD VOLUMES (vol4, vol5, ...)
REMOVE VOLUMES (vol1, vol2, ...)
[PASSWORD password]
ALTER STOGROUP TRG1T01
ADD VOLUMES (DBPK03)
REMOVE VOLUMES (DBPK01)
DDL - CREATE Database

◆ Syntax:
CREATE DATABASE database-name
[STOGROUP stogroup-name]
[BUFFERPOOL bufferpool-name]

CREATE DATABASE TRG1T01


STOGROUP TRG1T01
BUFFERPOOL BP0
DDL - CREATE TABLESPACE

CREATE TABLESPACE tablespace-name


IN database-name
USING STOGROUP stogroup-name
PRIQTY qty
SECQTY qty
ERASE YES/NO
LOCKSIZE
ANY/PAGE/TABLESPACE/TABLE/ROW
LOCKMAX SYSTEM/integer
BUFFERPOOL BP0/BP1/BP2/BP32K
CLOSE YES/NO
FREEPAGE <amount> PCTFREE <amount>
DDL - CREATE TABLEPSACE
Parameters

◆ PRIQTY:amount of physical storage


allocated when tablespace is created

◆ SECQTY:space taken as amount of data


in tablespace grows

◆ specified in KB
DDL - CREATE TABLESPACE
Parameters
◆ ERASE:
◆ Indicates whether the DB2 defined data
sets are to be erased when tablespace is
dropped
◆ LOCKSIZE:
◆ Indicates type of locking (Page /
Tablespace / Table / DB2 decided)
◆ LOCKMAX:
◆ Indicates max no of page or row locks
DDL - CREATE TABLESPACE
Parameters
◆ BUFFERPOOL:
◆ Buffer pool to be associated with
tablespace
◆ Default value is default buffer pool of
database
◆ CLOSE:
◆ Indicates whether data sets associated
with tablespace should be closed when
there are no current users of tablespace
DDL - CREATE TABLESPACE
Parameters
◆ FREEPAGE:
◆ Specified number of pages after which a
completely empty page is available
◆ Default is FREEPAGE 0

◆ PCTFREE:
◆ Specifies percentage of each page
available for future inserts
DDL - CREATE TABLESPACE
Parameters
◆ COMPRESS YES/NO:

◆ specifies whether data compression


applies to rows of the tablespace or
partition
◆ mapping of bit strings which are
frequently occuring to their
replacements stored in a compression
dictionary
DDL - CREATE INDEX
CREATE [UNIQUE] TYPE [1/2] INDEX ixname
ON tablename (colname [ASC/DESC], ...)
[ USING STOGROUP stogroupname
PRIQTY qty
SECQTY qty
ERASE YES/NO]
[CLUSTER] [SUBPAGES amount]
[BUFFERPOOL BP0/BP1/BP2]
[CLOSE YES/NO]
[PCTFREE amount] [FREEPAGE amount]
DB2 Program preparation

Refer DB2 application


programming DB2prep.ppt

Potrebbero piacerti anche