Introduction To IBM Universal Database For Linux, UNIX and Windows
Introduction To IBM Universal Database For Linux, UNIX and Windows
1. Database Objects
IBM Software Group
Agenda
Database Objects
Instances
Databases
Schemas
System catalog tables and views
Tables
Indexes
Views
IBM Software Group
Catalog Catalog
Index1 View1
View1 Index1
View3
IBM Software Group
Database Manager
Instance
Database1 Database2
DB2 Instance
WITH "comment-string"
TEMPORARY TABLESPACE | tblspace-defn |
tblspace-defn:
,
SYSTEM USING ( 'container-string' )
| MANAGED BY ,
DATABASE USING ( FILE 'container-string' number-of-pages )
DEVICE
Drive / Directory The drive or directory specified on the CREATE DATABASE command
DB2 Instance
DB2 Instance Name
Name The name of the DB2 instance owner
The partition number of the database, 0
NODE0000 for a non-partitioned database
SYSCAT v
...
i
SYSIBM.SYSCOLUMNS
SYSSTAT e
SYSIBM.SYSTABLES
w
...
s
IBM Software Group
Tables
A table is an unordered set of data records. It consists of columns
and rows that are generally known as records
Tables can either be permanent (base) tables, temporary
(declared) tables, or temporary (derived) tables
All database and table data is assigned to table spaces
The data in the table is logically related, and relationships can be
defined between tables
Data can be viewed and manipulated create table artists
(artno smallint not null,
based on mathematical principles name varchar(50) with default'abc',
classification char(1) not null,
and operations called relations bio clob(100K) logged,
picture blob( 10M) not logged compact)
in dms01
index in dms02
long in dms03;
IBM Software Group
Indexes
An index is a physical object that is associated with a single
table
Indexes are used to force uniqueness in a table (that is, to make
sure that there are no duplicate values) and to improve
performance when retrieving information
An index is a set of keys, each pointing to rows in a table. The
index allows more efficient access to rows in a table by creating
a direct path to the data through pointers
– The SQL optimizer automatically create unique index itemno on albums (itemno)
chooses the most efficient way
to access data in tables create index item on stock (itemno) cluster
Views
CONNECT TO TESTDB
CREATE VIEW EMPSALARY
AS SELECT EMPNO, EMPNAME, SALARY
FROM PAYROLL, PERSONNEL
WHERE EMPNO=EMPNUMB AND SALARY > 30000.00
IBM Software Group
Storage Objects
Table space
IBM Software Group
Table Spaces
File
Directory
Device
SMS
DMS
IBM Software Group
1
page
Container 0
0 2 Container 1
1
3
Extent
Extent = 32 Pages
(Default)
Tablespace B
IBM Software Group
1 page
– PREFETCHSIZE defined at I/O
Prefetch Read
– Can be altered with the
I/O Data access
ALTER TABLESPACE Server is faster
command
I/O
Server
24.1
OVERHEAD number-of-milliseconds
0.9
TRANSFERRATE number-of-milliseconds
IBM Software Group
Tablespace ID = 0
Name = SYSCATSPACE
Type = System managed space
Contents = Any data
State = 0x0000
Detailed explanation:
Normal
Total pages = 1729
Useable pages = 1729
Used pages = 1729
Free pages = Not applicable
High water mark (pages) = Not applicable
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
IBM Software Group
Tablespace ID = 5
Name = LONGTBS
Type = Database managed space
Contents = Long data only
State = 0x0000
Detailed explanation:
Normal
Total pages = 1024
Useable pages = 992
Used pages = 96
Free pages = 896
High water mark (pages) = 96
Page size (bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
IBM Software Group