The DB2 Database Manager Instance
The DB2 Database Manager Instance
7.0
Unit objectives
After completing this unit, you should be able to:
Review specifics of creating a database
Explore the System Catalog tables and views
Check and update Database configuration parameter settings
Compare DMS, SMS and Automatic Storage managed table spaces
Describe how to setup and manage a DB2 database with Automatic Storage
enabled
Define Storage Groups to manage databases with different classes of
storage available
Differentiate between table spaces, containers, extents, and pages
Create and alter table spaces
Create buffer pools to handle multiple page sizes or improve table access
efficiency
Use DB2 commands and SQL statements to display current table space
statistics and status information
Copyright IBM Corporation 2012
database2
Tablespace A
Tablespace B
Table 1
Table 2
Table 3
Table 4
Tablespace A
Table 1
Table 2
CREATE
database-name
AT DBPARTIONNUM
|Create Database Options|
ALIAS
db-alias
YES
NO
ON
,
USING CODESET
IDENTITY
path
drive
DBPATH ON
TERRITORY territory
4096
n K
DFT_EXTENT_SZ
dft-extentsize
RESTRICTIVE
WITH
"comment-string"
tblspace-defn:
|
codeset
PAGESIZE
COLLATE USING
path
drive
MANAGED BY
SYSTEM USING (
DATABASE USING (
EXTENTSIZE
OVERHEAD
|autoconfigure-settings|
,
)
'container-string'
,
FILE
'container-string'
DEVICE
num-pages
PREFETCHSIZE
number-of-milliseconds
TRANSFERRATE
num-pages
num-pages
number-of-milliseconds
Completed by
DB2 during database creation (1 of 2)
1. Creates database in the specified subdirectory
2. If Automatic storage is enabled a default storage group named
IBMSTOGROUP is created
3. Creates SYSCATSPACE, TEMPSPACE1, and USERSPACE1 table spaces
4. Creates the system catalog tables and recovery logs
5. Catalogs database in local database directory and system database
directory
6. Stores the specified code set, territory, and collating sequence
7. Creates the schemas SYSCAT, SYSFUN, SYSIBM, and SYSSTAT
8. Binds database manager bind files to the database (db2ubind.lst)
DB2 CLI packages are automatically bound to databases when the databases
are created or migrated. If a user has intentionally dropped a package, then
you must rebind db2cli.lst.
Copyright IBM Corporation 2012
Completed by
DB2 during database creation (2 of 2)
9. Grants the following privileges:
ACCESSCTRL , DATAACCESS , DBADM and SECADM
privileges to database creator
SELECT privilege on system catalog tables and views to PUBLIC
UPDATE access to the SYSSTAT catalog views
BIND and EXECUTE privilege to PUBLIC for each successfully
bound utility
CREATETAB, BINDADD, IMPLICIT_SCHEMA, and CONNECT
authorities to PUBLIC
USE privilege on USERSPACE1 table space to PUBLIC
Usage of the WLM workload for user class
SYSDEFAULTUSERCLASS to PUBLIC
Member-specific directory
The member-specific directory has the path:
your_instance/NODExxxx/SQLxxxx/
MEMBERxxxx
/database/inst481/NODE0000/SQL00001:
db2rhist.asc
db2rhist.bak
db2rhist.lock
HADR
load
LOGSTREAM0000 (Default database logs)
MEMBER0000
SQLDBCONF
SQLOGAB
SQLOGCTL.GLFH.1
SQLOGCTL.GLFH.2
SQLOGCTL.GLFH.LCK
SQLSGF.1
SQLSGF.2
SQLSPCS.1
SQLSPCS.2
/database/inst481/NODE0000/SQL00001
/LOGSTREAM0000:
S0000000.LOG
S0000001.LOG
S0000002.LOG
/database/inst481/NODE0000/SQL00001
/MEMBER0000:
db2event
DB2TSCHG.HIS
HADR
SQLBP.1
SQLBP.2
SQLDBCONF
SQLINSLK
SQLOGCTL.LFH.1
SQLOGCTL.LFH.2
SQLOGMIR.LFH
SQLTMPLK
Default
table space containers with Automatic Storage
CREATE DATABASE DSS ON /dbauto DBPATH ON /database
dbauto
DB2INSTANCE=inst20
inst20
NODE0000
DSS
T0000000
SYSCATSPACE
C0000000.CAT
T0000001
TEMPSPACE1
C0000000.TMP
T0000002
C0000000.LRG
Copyright IBM Corporation 2012
USERSPACE1
S Y S S T A T
v
i
e
w
s
S Y S IB M .S Y S C O L U M N S
S Y S IB M .S Y S T A B L E S
...
S Y S C A T
...
TABLE SPACE
CONTAINER
EXTENT
DATA
PAGE
File
Directory
Device
Directory
File
Device
SMS
DMS
DMS
Writing to containers
DFT_EXTENT_SZ defined at database level
EXTENTSIZE defined at table space level
Data written in round-robin manner
Container 0
Container 1
1
Extent
Table space TBS
Copyright IBM Corporation 2012
Large RIDs
64
GB
128
GB
8 KB
4
KB
256
GB
16 KB
512
GB
32 KB
8
TB
16
TB
8 KB
32
TB
16 KB
64
TB
32 KB
Page size
Page size
table space size
16M
255
4x109 Rows
16M
512M
~2K
1.1x1012 Rows
CREATE
tablespace-name
REGULAR
SYSTEM
TEMPORARY
PAGESIZE 4096
USER
PAGESIZE integer
db-partition-group-name
IN
MANAGED BY
PREFETCHSIZE
AUTOMATIC
num-pages
integer
OVERHEAD
BUFFERPOOL
K
M
G
number-of-milliseconds
Inherit
TRANSFERRATE
bufferpool-name
number-of-milliseconds
Inherit
ON
OFF
YES
NO
AUTORESIZE
K
M
G
system-containers:
MAXSIZE int
K
M
G
NONE
,
USING
'container-string'
)
| on-db-partitions-clause |
database-containers:
USING
| container-clause |
| on-db-partitions-clause |
container-clause:
,
(
FILE
'container-string'
DEVICE
on-db-partitions-clause:
num-pages
integer
K
M
G
,
ON
DBPARTITIONNUM
db-partition-number1
TO
DBPARTITIONNUMS
Copyright IBM Corporation 2012
db-partition-number2
Partition
Automatic
Storage
Table Space
2012Q1
Table Space 14
New
2011Q2
Table Space 11
Table Space 10
Table Space 9
Table Space 1
spath: /hot/fs1
Storage
Group
2011Q3
2011Q4
SG_HOT
spath: /warm/fs1
spath: /warm/fs2
SG_WARM
spath: /cold/fs1
spath: /cold/fs2
spath: /cold/fs3
SG_COLD
Physical Disk
SSD RAID Array
STORAGE_GROUP
STORAGE_GROUP_ID STORAGE_PATH
DB_STORAGE_PATH_STATE
-------------------- ---------------- -------------------- --------------------IBMSTOGROUP
0 /dbauto/path1
IN_USE
APP_DATA
1 /dbauto/path2
IN_USE
TOTAL_PATH_MB
PATH_FREE_MB
-------------------- -------------------20940
5649
20940
5649
2 record(s) selected.
Name
IBMSTOGROUP
SG_HIGH
SG_LOW
Numpaths
2
2
2
PathState
InUse
InUse
InUse
InUse
InUse
InUse
NumDropPen
0
0
0
PathName
/dbauto/path1
/dbauto/path2
/dbauto/path1/sg_high
/dbauto/path2/sg_high
/dbauto/path1/sg_low
/dbauto/path2/sg_low
Examples: CREATE
CREATE
CREATE
CREATE
CREATE
ALTER TABLESPACE
ALTER TABLESPACE can be used to change table space
characteristics:
For all types table space management, you can adjust:
Bufferpool assigned
Prefetch size
Overhead and Transfer rate I/O Costs
File System Caching option
DEFINER
TBSPACEID
TBSPACETYPE
---------- ----------- ----------SYSIBM
0 D
INST28
9 D
INST28
3 D
SYSIBM
2 D
SYSIBM
1 S
INST28
7 D
INST28
8 D
INST28
4 D
INST28
5 D
INST28
6 D
INST28
10 S
11 record(s) selected.
DATATYPE
-------A
A
L
L
T
L
L
A
L
L
A
SGNAME
-----------IBMSTOGROUP
IBMSTOGROUP
IBMSTOGROUP
IBMSTOGROUP
IBMSTOGROUP
APP_DATA
APP_DATA
-
Id
0x9396EEC0 0
DMS
Regular 4096
Yes
..SYSCATSPACE
0x93977C90 1
SMS
SysTmp
4096
32
Yes
32
..TEMPSPACE1
0x93982990 2
DMS
Large
4096
32
Yes
32
..USERSPACE1
0x95727700 3
DMS
Large
4096
Yes
..SYSTOOLSPACE
0x957B92B0 4
DMS
Regular 4096
Yes
..TSP01
0x957C58B0 5
DMS
Large
4096
Yes
..TSP02
0x957D8760 6
DMS
Large
4096
Yes
..TSP03
0x957E0EC0 7
DMS
Large
4096
Yes
..TSP04
0x957E9620 8
DMS
Large
4096
Yes
..TSP05
0x957F1D80 9
DMS
Regular 4096
Yes
..TSP06
0x957FA4E0 10
SMS
Regular 4096
Yes
..SMS01
Tablespace Statistics:
Address
Id
TotalPgs
UsablePgs
UsedPgs
PndFreePgs FreePgs
HWM
0x9396EEC0 0
24576
24572
20696
3876
20696
0x93977C90 1
..
Copyright IBM Corporation 2012
Example
To list table spaces ordered by number of physical reads from table space
containers.
SELECT varchar(tbsp_name, 30) as tbsp_name,
member,
tbsp_type,
pool_data_p_reads
FROM TABLE(MON_GET_TABLESPACE('',-2)) AS t
ORDER BY pool_data_p_reads DESC
TBSP_NAME
MEMBER TBSP_TYPE POOL_DATA_P_READS
------------------------------ ------ ---------- -------------------SYSCATSPACE
0 DMS
79
USERSPACE1
0 DMS
34
TEMPSPACE1
0 SMS
0
...
=
=
=
=
=
=
=
TESTDB
OURDB
/database
a.00
Test Database
Indirect
4
Database configuration
DEACTIVATE DATABASE
Databases initialized by ACTIVATE DATABASE can be shut down
using the DEACTIVATE DATABASE command, or using the
db2stop command.
db2 deactivate db <db_name>
Unit summary
Having completed this unit, you should be able to:
Review specifics of creating a database
Explore the System Catalog tables and views
Check and update Database configuration parameter settings
Compare DMS, SMS and Automatic Storage managed table spaces
Describe how to setup and manage a DB2 database with Automatic Storage
enabled
Define Storage Groups to manage databases with different classes of
storage available
Differentiate between table spaces, containers, extents, and pages
Create and alter table spaces
Create buffer pools to handle multiple page sizes or improve table access
efficiency
Use DB2 commands and SQL statements to display current table space
statistics and status information
Copyright IBM Corporation 2012
Student exercise