DB2 UDB The Basics: Keith E. Gardenhire
DB2 UDB The Basics: Keith E. Gardenhire
Introduction
DB2 UDB V8.2 Basic Database Administration
Products
DB2 Enterprise Server Edition DB2 Workgroup Server Unlimited Edition DB2 Workgroup Server Edition DB2 UDB Express Edition DB2 Personal Edition
3
Ethernet
Node 1
Node 2
Node 3
Node 4
Data
Data
Data
Data
Instance
Manages one or more databases Must have root or Administrator Authority to create
db2icrt -u fencedusr instance_name db2start db2stop will start an instance will stop an instance
Table Space
Logical layer between Hardware and Database Comprised of one or more containers A container is a file or a directory REGULAR
CREATE
LARGE SYSTEM
TABLESPACE name
TEMPORARY
USER MANAGED BY
8
SYSTEM DATABASE
system-containers database-containers
2005 IBM Corporation
System Containers
SMS Containers USING (container string)
DMS Containers
USING (FILE container string number of pages) (DEVICE container string number of pages)
10
Create Tables Command Line db2 create table ARTISTS ( ARTNO NAME SMALLINT NOT NULL, VARCHAR(40),
create table warehouse (itemno smallint, warehousename char(20), qty integer ) in dms03d;
The script file cr_warehouse contains the above info db2 tvf cr_warehouse
12
13
Describe Indexes
14
Moving Data
Moving Data
IMPORT
EXPORT LOAD
db2move
16
Import / Export
Import
File
Export
17
IMPORT utility
IXF
DEL ASC
INSERT INTO
INSERT_UPDATE
table-name
REPLACE
18
REPLACE_CREATE
Export
EXPORT TO file OF IXF DEL WSF MESSAGES message-file
select statement
19
LOAD 1) Load Loads data, collects index keys 2) Build creates the indexes
20
RESTART
TERMINATE
21
22
DB2MOVE
db2move
Database
db2mov e
db2move.lst
table.ixf
23
load
tc table-creators
tn table-name
sn schema-names ts
24
table space-names
2005 IBM Corporation
GUI Tools
26
27
28
29
30
31
32
Command Editor
33
Visual Explain
34
Visual Explain
35
Task Center
36
Journal
37
RECOVERY
Recovery
Defining logs Recovery of database
39
Database
S0000000.log
S0000001.log
S00000002.log
40
Database
S0000000.log
S0000001.log
S00000002.log
S0000003.log
S0000004.log
41
Backup
If LOGRETAIN = Recovery you may backup table space or database
If LOGRETAIN = NO you may only backup database
42
Recovery
If LOGRETAIN = NO, you may only recover the database
If LOGRETAIN = RECOVERY, you may recover a table space or a database from a full database backup
43
Modes of Recovery
Offline Online RESTORE DB database-name FROM file TAKEN AT time
TO isotime
END OF LOGS
AND STOP
44
Database1
Laptop computer
Database_standby
45
47
48
Configuration Parameters
49
Buffer Pool
Buf f er Pool
Database
50
51
Sort Heap
Sorts are done in sortheap
If no space for sort data is moved to TEMPSPACEn GET SNAPSHOT FOR ALL ON database
52
Package Cache
Dynamic SQL statements
Package Cache
53
LOCK
Locks are held to prevent loss of data
Lock Row / Table / Table Space LOCKLIST
MAXLOCKS
ALTER TABLE table-name LOCKSIZE TABLE
54
Show Locks
55
SQL Statements
Determine which statement is causing the majority of problems
Determine what might be causing the problem
56
57
Visual Explain
58
Table Statistics
59
Performance Summary
Buffer pools
Numerous Database Configuration parameters SQL Statement Tuning
60
Security
Security
Security is used at the operating system level
Table access is through the database
62
Instance Level
SYSADM_GROUP
SYSCTRL_GROUP SYSMAINT_GROUP
SYSMON_GROUP
63
GRANT / REVOKE
GRANT access to an object/program
REVOKE access to an object/program GRANT SELECT ON TABLE ARTISTS TO USER1
64
Summary
The Relational Database can be simple or complex
The database structure is simple, Table spaces, Tables, etc. Recovery is straight forward
65
McClean, VA 22102
Suite 120 First Floor WebSphere Information Integrator July 14, 2005 Contact: Keith E. Gardenhire [email protected]
66
67