Escolar Documentos
Profissional Documentos
Cultura Documentos
Amit Daharwal
IT Specialist – IBM Academic Initiative
2
IBM DB2 9
More on instances
The default instance for a particular system is defined by the
DB2INSTANCE environment variable. Initially for Windows
default is ‘DB2’ and for Linux/Unix it is ‘db2inst1’.
DB2 9 Instance Management Commands:
Command Purpose
db2icrt [InstanceName] Creates a new instance
db2idrop [InstanceName] Deletes (drops) an existing instance
db2ilist Lists all instances that have been defined
db2start Starts the DB2 Database Manager background
processes for the current instance
db2stop Stops the DB2 Database Manager background
processes for the current instance
4
IBM DB2 9
5
IBM DB2 9
Tablespaces
A tablespace is a logical layer between data and storage
devices.
Consists of one or more containers.
Tables, regular data, indexes, and long data reside in
tablespaces
SQL: CREATE / DROP / ALTER TABLESPACE
To display Table space info:
LIST TABLESPACES [SHOW DETAIL]
Details about containers can be obtained with following
command.
LIST TABLESPACE CONTAINERS FOR tablespace_id
[SHOW DETAIL]
7
IBM DB2 9
Types of Tablespaces
System-Managed Space (SMS):
OS’s file system manager allocates and manages the space.
Database-Managed Space (DMS):
Here, the database manager controls the storage space.
Automatic Storage With DMS:
Databases that are enabled for automatic storage have a set
of one or more storage paths associated with them.
A table space can be defined as "managed by automatic
storage" and its containers assigned and allocated by DB2
based on those storage paths.
You cannot enable/disable automatic storage once it is
defined for database.
Default type in DB2 9.
8
IBM DB2 9
9
IBM DB2 9
Database
The database contains following objects:
Tables, views, indexes, schemas, Locks, triggers, stored
procedures, packages, Buffer pools, log files, table spaces
Tools, which can help you create DB2 9 database are First
Steps, Control Center [ Using GUI Wizard ] and Command
Line Processor (CLP).
Some database commands -
CREATE DATABASE To create a database. (Database name
<dbname> can not begin with "SYS", "DBM", or "IBM“)
CONNECT TO <dbname> To connect to a database
CONNECT RESET To terminate connection
DROP DATABASE <dbname> To drop database
10
IBM DB2 9
Cataloging
DB2 automatically catalogs databases when they are
created. It catalogs an entry for the DB in the local database
directory and another entry in the system database directory.
Without catalog information, an application cannot connect to a
DB. DB2 has multiple directories that are used to access DBs.
The database directory contains a list and pointer to where
all the known databases can be found. (list db directory)
The node directory contains information relating to how and
where remote instances can be found. (list node directory)
The Database Connection Services (DCS) Directory
contains information relating to how and where databases on
DRDA systems can be found. (list dcs directory)
12
IBM DB2 9
14
IBM DB2 9
15
IBM DB2 9
16
IBM DB2 9
17
Click
IBM DB2 9
Enter IP address or
Default port on Machine Name
Windows : 50000
19
Click
IBM DB2 9
Choose protocol
(e.g. TCP/IP)
20
Click
IBM DB2 9
21
Click
IBM DB2 9
22
Click
IBM DB2 9
23
Click
IBM DB2 9
24
Click
IBM DB2 9
26
IBM DB2 9
27
IBM DB2 9
30
IBM DB2 9
33
IBM DB2 9
35
IBM DB2 9
37
IBM DB2 9
A. Sequence
B. Trigger
B.
C. View
D. Schema
E. Table
42
IBM DB2 9
A. Sequence
B. Identity column
C. Trigger
D. Table function
43
IBM DB2 9
44
IBM DB2 9
45
IBM DB2 9
46
IBM DB2 9
A. Routine
B. Function
C. Procedure
D. Trigger
47
IBM DB2 9
48
IBM DB2 9
49
IBM DB2 9
Grazie Hebrew
Italian
Gracias
Spanish
Russian
Obrigado
Thank
Portuguese
Arabic
Merci
French
Traditional Chinese
You English
Danke
German
Thai
Simplified Chinese Tamil
Japanese Korean
50