This document provides an overview of various database administration concepts in DB2 including tables, views, indexes, procedures, triggers, tablespaces, and buffer pools. It discusses how tables are used to store column and row data, and how system catalog tables track metadata. It also describes views, indexes, procedures, triggers, how they are used and created. The document outlines how tablespaces are used to logically group database objects and storage, and how buffer pools cache data pages in memory to improve performance.
3. Tables are logical structure maintained by Database manager. In a table
each vertical block called as column (Tuple) and each horizontal block
called as row (Entity). The collection of data stored in the form of columns
and rows is known as a table. In tables, each column has different data
type.
3
5. Each DB2 database has a set of tables called the system catalog tables.
DB2 creates these tables when a database is created.
• DB2 creates the system catalog base tables under the SYSIBM schema like
SYSIBM.SYSTABLES,SYSIBM.SYSVIEWS,SYSIBM.SYSPACKAGES.
• These tables are not erasable.
• DB2 optimizer uses these to track the changes happening to the db2
objects.
5
6. All the tables created by DBAs will come under this category. All the tables
will be placed in usersapace1 table space by default
db2 " create table customers (id integer primary key not null, name
varchar(50), age integer)”
db2 " insert into customers values (11,‘abc',27)”
• db2 "select * from customers”
• db2 " select tabname, tabschema, tbspace from syscat.tables“
• db2 " select tabname, tabschema, tbspace from syscat.tables"| grep -i
customers
• db2 describe table customers
6
7. Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ID SYSIBM INTEGER 4 0 No
NAME SYSIBM VARCHAR 50 0 Yes
AGE SYSIBM INTEGER 4 0 Yes
db2 " alter table customers alter column ID set data type bigint"
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ID SYSIBM BIGINT 8 0 No
NAME SYSIBM VARCHAR 50 0 Yes
AGE SYSIBM INTEGER 4 0 Yes
7
8. db2 "alter table customers rename column NAME to NICKNAME”
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ID SYSIBM BIGINT 8 0 No
NICKNAME SYSIBM VARCHAR 50 0 Yes
AGE SYSIBM INTEGER 4 0 Yes
db2 "drop table customers“
8
9. For temporary work of different database
operations, DB2 uses temporary tables. The
temporary tables do not appear in system catalog.
9
10. View is an alternative way of representing the data stored in the tables. It is
not an actual table and it does not have any permanent storage. View
provides a way of looking at the data in one or more tables.
• db2 “create view view_sales1(id, itemname, qty, price) as select id,
itemname, qty, price from shopper.sales1”
• SYSIBM.SYSVIEWS ,SYSCAT.VIEWS
• db2 drop view <view_name>
• SYSCAT.TABLES, SYSCAT.VIEWS,SYSCAT.TABLESPACES are the
examples of view subjected to system catalog tables
SYSIBM.SYSTABLES,SYSIBM.SYSVIEWS and
SYSIBM.SYSTABLESPACES respectively.
10
11. Indexes are an ordered set of keys each pointing to a row in a table. They improve
application performance when looking for specific rows.
Indexes are database objects that are built based on one or more columns of a table.
They are used for two main reasons:
• To improve query performance. Indexes can be used to access the data faster
using direct access to rows based on the index key values.
• To guarantee uniqueness when they are defined as unique indexes.
SYSIBM.SYSINDEXES , SYSCAT.INDEXES
db2 describe indexes for table customers show detail
11
12. To create an index, use the CREATE INDEX statement. This statement requires at a
minimum:
• The name of the index
• The name of the associated table
• The columns that make up the index (also known as index keys)
In addition, you can specify the following:
• Whether the index is unique (enforce uniqueness for the key values) or non-
unique(allow duplicates)
• Which order DB2 should use to build and maintain the key values: ascending (ASC,
the default) or descending (DESC) order
• Whether to create INCLUDE columns that are not part of the index key but are
columns often retrieved by your queries
12
13. db2 “CREATE UNIQUE INDEX company_ix ON
company (company_ID ASC, name DESC)
INCLUDE (no_employees)”
13
14. A package is a database object consisting of executable SQL, including the access
path the DB2 optimizer will take to perform the SQL operation.
14
16. Procedures are programs whose executable binaries reside at the database server.
They serve as subroutines to calling applications, and they normally wrap multiple
SQL statements with flow logic. They are used to reduce the traffic so improving the
performance.
Besides improving response time for applications running on a different server than
the database server, stored procedures also provide a central location to store
database application logic. This allows for a single place to maintain your code.
16
18. There are 2 types of procedures in DB2 .
1. Fenced Procedure
2. Unfenced Procedure
A fenced stored procedure runs in a different address space than the DB2
engine. This guarantees that a failure from the procedure will not corrupt the
DB2 engine itself. In Linux and UNIX, a fenced user needs to be created to
work with fenced stored procedures.
In terms of performance, unfenced stored procedures run faster than fenced
ones; however, there is a risk that unfenced procedures may corrupt DB2
information,
18
19. A trigger is a database object associated to a table or a view that contains some
application logic, which is executed automatically upon an INSERT, UPDATE, or
DELETE operation on the table or view.
Triggers can be classified as BEFORE, AFTER, or INSTEAD OF triggers.
Example of Before Trigger
CREATE TRIGGER default_time NO CASCADE BEFORE INSERT ON schedule
REFERENCING NEW AS n FOR EACH ROW MODE DB2SQL
WHEN (n.start_time IS NULL) SET n.start_time = '12:00'
19
20. CREATE TRIGGER audit_qty
AFTER UPDATE OF quantity ON inventory
REFERENCING OLD AS o NEW AS n
FOR EACH ROW
MODE DB2SQL
INSERT INTO sold
VALUES (n.product_ID, n.daysold, o.quantity - n.quantity)
20
21. This example demonstrates how a read-only view can still be updated by
using INSTEAD OF triggers. In the example, the trigger updates the region
column of table table2 when the view view2 (a read-only view) is updated.
CREATE TRIGGER update_view2 INSTEAD OF UPDATE
ON view2 REFERENCING OLD AS o NEW AS n
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC UPDATE table2
SET region = n.region
WHERE region = o.region;
END
21
22. DB2 stores table and index data on a page, which is the smallest unit of storage in a DB2
database.
DB2 creates and manages the pages in the table space automatically, but you can control
the page size for your table spaces. If you do not explicitly specify the page size when you
create
the table space, DB2 will use the default size of 4K. DB2 supports four different page sizes:
4K,8K, 16K, and 32K.
The maximum number of rows on a page is 255 rows. This is significant, if you have small
row sizes.
A table space may contain up to 64 GB of data, if the page size is 4K.
Chunk of pages are called as Extent
22
23. A table space is a storage structure, it contains tables, indexes, large
objects, and long data. It can be used to organize data in a database into
logical storage group which is related with where data stored on a system.
23
24. The table spaces are beneficial in database in various ways given as
follows:
Recoverability: Tablespaces make backup and restore operations more
convenient. Using a single command, you can make backup or restore all
the database objects in tablespaces.
Automatic storage Management: Database manager creates and extends
containers depending on the needs.
Memory utilization: A single bufferpool can manage multiple tablespaces.
You can assign temporary tablespaces to their own bufferpool to increase
the performance of activities such as sorts or joins.
24
25. When you create a new database, the database
manager creates some default tablespaces for
database. These tablespace is used as a storage
for user and temporary data. Each database must
contain at least three tablespaces as given here:
Catalog tablespace
User tablespace
Temporary tablespace
25
26. 26
Logical layer between Hardware and Database
Comprised of one or more containers
A container is a file or a directory
REGULAR
CREATE TABLESPACE name
LARGE
SYSTEM
TEMPORARY
USER
MANAGED BY SYSTEM system-containers
DATABASE database-containers
27. 27
SMS Containers
USING (‘container string’)
DMS Containers
USING (FILE ‘container string’ number of pages)
(DEVICE ‘container string’ number of pages)
28. 28
CREATE TABLESPACE TS1 MANAGED BY SYSTEM
USING (‘/home/inst01/database/ts1’)
CREATE TABLESPACE DMS01D MANAGED BY DATABASE
USING (FILE ‘C:DMSDATABASEDMS01D’ 1000)
30. The database buffer pool area is a piece of real memory that is used by DB2
to temporarily store (cache) the regular data and index pages when they are
read from disk to be scanned or modified.
The buffer pool area improves the performance of the database, since the
pages can be accessed
much more quickly from memory than from disk.
30
31. When you create a database, DB2 creates a default buffer pool named
IBMDEFAULTBP.
CREATE BUFFERPOOL tempbp SIZE 10000
ALTER TABLESPACE tempspace1 BUFFERPOOL tempbp
CREATE BUFFERPOOL bp16k SIZE 100000 PAGESIZE 16K
ALTER BUFFERPOOL bp16k SIZE 200000
31
32. You will not be able to drop any buffer pools that are
associated with a table space. Before you can drop the
buffer pool you will need to associate the table space
with a different buffer pool using the ALTER
TABLESPACE statement.
DROP BUFFERPOOL bp16k
32
33. db2 get snapshot for bufferpools on database-name
Bufferpool name = IBMDEFAULTBP
Database name = MUSICKEG
Database path = C:DB2NODE0000SQL00002
Input database alias = MUSICKEG
Snapshot timestamp = 05/04/2005 13:11:37.329018
Buffer pool data logical reads = 336
Buffer pool data physical reads = 129
33
37. 37
IMPORT FROM filename OF IXF
DEL
ASC
LOBS FROM lob-path MODIFIED BY options
MESSAGES
INSERT INTO table-name
INSERT_UPDATE
REPLACE
REPLACE_CREATE
38. 38
EXPORT TO file OF IXF MESSAGES message-file
DEL
WSF
select statement
39. 39
1) Load Loads data, collects index keys
2) Build creates the indexes
3) Delete Delete unique key violations place into
exception tables.
4) Index Copy – copy indexes from temp table space
40. 40
LOAD FROM filename OF IXF
ASC
DEL
LOBS FROM lob-path MODIFIED BY options
MESSAGES message-file
INSERT INTO table-name
REPLACE
RESTART
TERMINATE
41. 41
Create nickname sales for
another database SAMPLE table SALES
Create nickname employee for
another database SAMPLE table EMPLOYEE
DECLARE C1 CURSOR FOR SELECT SALES.SALES_PERSON,
LASTNAME, FIRSTNME FROM SALES, EMPLOYEE
WHERE SALES_PERSON = EMPLOYEE.LASTNAME
LOAD FROM C1 OF CURSOR INSERT INTO LOCAL_SALES
50. If LOGRETAIN = Recovery you may backup table space
or database
If LOGRETAIN = NO you may only backup database
BACKUP DB database-name ONLINE to C:backup
INCLUDE LOGS
50
51. 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
51
52. Offline
Online
RESTORE DB database-name FROM file TAKEN AT
time
ROLLFORWARD DATABASE database-name
TO isotime AND STOP
END OF LOGS
52
71. GRANT access to an object/program
REVOKE access to an object/program
GRANT SELECT ON TABLE ARTISTS TO
USER1
71
72. The Relational Database can be simple or complex
The database structure is simple, Table spaces, Tables,
etc.
Recovery is straight forward
Database maintenance can be automated
Tuning the database is a life long endeavor
72
73. July 12, 13 DB2 UDB Administration Proof of
Technology
IBM – McClean Tec
8401 Greensboro Drive
McClean, VA 22102
Suite 120 First Floor
WebSphere Information Integrator July 14, 2005
Contact: Keith E. Gardenhire
keithgar@us.ibm.com
73
This presentation will discuss DB2 UDB Fundamentals.
There are two types of table space management systems: Database and System. System managed table space is easier to maintain. Database managed space is slightly faster than System managed space when adding data to a table. The reason is that DMS table space will format data pages in advance. SMS managed space has significant performance improvements in DB2 UDB V8.1. SMS table space will acquire an extent at time on DB2 V8.1, where on previous release DB2 UDB obtained 1 page at a time.
If you use SMS table space, the entire table must exist in the one table space.
If you use DMS table space, the table may have the data portion in one table space, the index in a second table space and the large object portion in a third table space.
Table space definition will set the page size. The default page size is 4K. Page sizes can be 4K, 8K, 16K and 32K.
The maximum number of rows on a page is 255 rows. This is significant, if you have small row sizes.
A table space may contain up to 64 GB of data, if the page size is 4K.
Table spaces may be managed by System requires a directory. The directory will be created.
Table spaces managed by Database requires a file or raw device.
The table space named TS1 is an SMS table space. If the directory does not exist, it will be created.
The table space named DMS01D is a DMS table space. Data will be placed in a file.
A logical read occurs when DB2 attempts to find a page in the buffer pool. A physical read occurs, when the page requested is not in the buffer pool.
Populating data into tables. IMPORT inserts data into tables.
LOAD utility used for loading large amounts of data is faster than the IMPORT utility.
Export utility moves data from a table to a flat file.
db2move is a utility that may move many tables at the same time.
The Import utility will take the data from a flat file and place it into table. Inserts will be used to place the data into the table.
The inserts will be logged. Triggers, if they exist, will be executed. DB2 UDB V8.2 will allow Online IMPORT. This means that users may access the table, while the IMPORT utility is running.
The IMPORT utility will insert data into a table.
The format of the input file is IXF (PC/Integrated Exchange format) used by DB2 only.
DEL indicates a delimited ASCII format. The columns will be delimited by a comma. Character columns will be delimited by a double quote mark.
ASC indicates an ASCII file with a column beginning and ending position of the data. If you use the ASC file type the METHOD L must be used to state the beginning and ending position.
Example:
IMPORT FROM ARTISTS.DAT OF ASC LOBS FROM C:\LOBS\ MODIFIED BY LOBSINFILE
METHOD L ( 40 43, 1 39, 50 69, 70 83, 84 98) MESSAGES IMPORT_ARTISTS.MSG
INSERT INTO ARTISTS
Export data from a table(s) and place data into file. With the Export utility you can take data from more than one table. Any valid SELECT statement may be used. The SELECT statement may even be JOIN.
The 4 phases from load.
The Load command is used for placing large amounts of data into the table.
When using the load command, exception tables should be created. The exception tables are identical to the original table. The exception table may have two additional columns: TS (Timestamp) and MSG (CLOB 32K).
If you do not have an exception table and a row violates referential integrity, the LOAD will fail.
Note: If you are running the DPF (Data Partitioning Feature), the exception table must be in the same partitions as the original table.
The LOAD utility supports using a cursor. This is a way to load data from tables that do not exist in the database. The nickname is a federated database concept. The nickname will refer to table in a separate database. The federated database concept allows access to non-IBM database stores.
db2move is the Database Movement Tool.
db2move is a tool that allows the DBA to copy a large number of tables using one command. Tables will be exported in the PC/IXF format. The tables can be imported and exported into another DB2 database.
The db2move tool will create a db2move.lst file that will contain the table name resolution file.
Each table will have an tab.ixf file associated with the table data.
db2move can export only the tables with a specific schema name, table name, or who created the table. The db2move can also import the tables. If the table does not exist, the db2move utility is able to create the table if the import is done.
Table space TS1 is managed by the system so a directory “\sms\musickeg\ts1” will be created. Table space DMS01D is managed by the database so a file of 161 4K pages will be used. The table space DMS01I will be managed by the database and a file of 48 pages will be created.
Creating a table space using the Control Center. Open the Control Center. Expand the tree for the database you want to create the table space. In this case let us use the database MUSICKEG. Select the “+” to left of the database.
When the database is started, either by the first connect or using the “ACTIVATE DATABASE” command, the primary log files are allocated. The number of primary logs is defined by the database configuration parameter LOGPRIMARY. When LOGRETAIN = NO (Database Configuration parameter) and the primary log files are full, the secondary log files will be allocated.
LOGPRIMARY indicates the number of log files that will be allocated when the database starts.
LOGSECOND indicates the maximum number of secondary log files that can be allocated. If you set LOGSECOND to a -1, an infinite number of secondary log files can be allocated.
When LOGRETAIN = RECOVERY, log files are maintained. When the primary log files are used, additional log files will be created.
Backup in DB2 UDB V8.2 will allow the logs to backed up at the same time as the database. You may only include the logs only in an online backup.
BACKUP DB database-name ONLINE to c:\backup INCLUDE LOGS
This command will include the log files with the backup.
If LOGRETAIN=NO, you may only do offline backups.
Offline backup no one can access the database during a backup.
Online backup will allow users to be accessing the database at the time the backup is executing.
If LOGRETAIN=RECOVERY, a table space(s) may be recovered from a full database backup.
When the restore is finished, the database is left in a roll forward pending state. If the database configuration parameter LOGRETAIN = RECOVERY, the DBA (database administrator) may recover the database to a point in time.
The RECOVER DATABASE command combines both RESTORE DATABASE and ROLLFORWARD DATABASE commands.
HADR allows for a standby database. The standby database is used, if the primary database is unavailable. The clients will be automatically rerouted to the standby database. To invoke the HADR feature update the database configuration. If the standby database does not hear from the primary database is 120 seconds (default), the standby database takes over.
HADR is not available with the DPF (Data Partitioning Feature)
Let us cover a few simple performance and tuning options of using DB2.
The Configuration Advisor allows the DBA to answer several questions. DB2 UDB will then set the configuration parameters.
As with any performance configuration parameters your performance improvement may vary.
Each person has there own personal preferences.
There is one default buffer pool. The buffer pool is named IBMDEFAULTBP and is 250 4K pages on a Windows operating system and 1000 4K pages on a UNIX operating system. When page is requested, DB2 will search the buffer pool first. If the page is not in the buffer pool, DB2 will issue a physical I/O request. Therefore it is imperative to keep pages, that are needed in the buffer pool.
Suggestion: In an OLTP (Online Transaction Processing ) environment you would want high impact tables in a buffer pool by itself. For DSS (Decision Support Systems) one large buffer pool should suffice.
The command “GET SNAPSHOT FOR TABLES ON database” will produce what tables are accessed the most.
If you change page sizes from the default 4K page, make sure that a buffer pool is made with the same size.
It is probably better to keep sort data in memory. Sort overflows indicate data to be sorted did not fit in memory.
The command “GET SNAPSHOT FOR ALL ON database” will show how many sort overflows have occurred.
The database configuration parameter SORTHEAP should be adjusted to eliminate a number of the sort heaps.
If the SORTHEAP is not big enough, DB2 will overflow the sort into TEMPSPACE. Note: If you change a page size from the default size of 4K, you must also create TEMPORARY table space of that size.
A dynamic SQL statement is executed. The database manager will verify if the statement is in package cache (package cache lookup). If the SQL statement is not in package cache, the statement is compiled and placed in package cache (package cache insert). If there are no sections available in package cache, a package cache overflow will occur.
When package cache overflows, it expands dynamically.
You may flush package cache with the command:
FLUSH PACKAGE CACHE DYNAMIC
Package cache is allocated at database start up time. Look for the database parameter PCKCACHESZ (it is a calculated value of MAXAPPLS * 8).
By default a row is locked. The LOCKLIST is number of 4K pages, that will hold all the lock request blocks. MAXLOCKS determines the percentage of locklist that 1 user may hold. If this percentage is exceeded, the lock request blocks will updated into one table lock. Lock escalation normally indicates a problem. Changing the default row level locking for a table to table level, especially if the table is read only is a good idea.
A LOCKWAIT occurs when a user is waiting on an object in the database. This slide shows two users, DBAPOT and ADMIN, waiting for a resource held by user KGARDEN.
From the Control Center select the instance named “DB2” with the RMB (Right Mouse Button). From the pop-up menu select the Applications (menu item). Highlight the user holding the lock and select the command button Show Lock Chains.
The Activity monitor (new to DB2 UDB V8.2) is able to assist in finding the high impact SQL statements.
Visual Explain and the character explain tools are able to show the access path of a single SQL Statement.
The Design Advisor is able to suggest indexes and MQT (Materialized Query Table), that may help in deciding what may improve performance of the SQL statement.
To get to this point
Open the Control Center -&gt; Select the database with the RMB (Right Mouse Button) -&gt; Activity Monitor
Determine the SQL Statement that is causing the problem. In this example select the Report:
Dynamic SQL statements in the cache with the longest average execution time.
From here you can select the SQL Statement and execute Visual Explain.
In this case an index was used for the table TITLES. Notice the diamond above the table DBAPOT.TITLES. This diamond indicates an index is being used. A table scan was run against the tables WAREHOUSE and ARTISTS. DB2 UDB has a cost based optimizer so it is important to have statistics up to date.
If you double click on the tables (rectangle), the table statistics will be displayed.
Notice the STATS_TIME row.
There are many things that may affect performance. These are just a couple of tuning tips.
All these groups should be defined to the operating system. If the group is defined in the operating systems security, any userid in that group has the authority.
The SYSMON_GROUP is new for DB2 UDB V8.1. Users in this group will be able issue GET DATABASE MANAGER MONITOR SWITCHES, GET MONITOR SWITCHES, GET SNAPSHOT, LIST ACTIVE DATABASES, LIST APPLICATIONS, RESET MONITOR SWITCHES and UPDATE MONITOR SWITCHES.
DB2 UDB Administration for the Oracle DBA
For the Distributed Database on Linux, Windows, UNIX. Hands on Labs on Windows workstation.
Date: July 12, 13, 2005 (Tuesday and Wednesday)
Start Time: 09:00 A.M.
End Time: 05:00 P.M.
Location:
IBM Technology Center
8401 Greensboro Drive
McClean, VA 22102
Suite 120 (First Floor)
Customers who would like to attend contact:
Keith E. Gardenhire
e-mail: [email_address]
Phone: (301)803-1717
I am doing a 2 day class DB2 UDB V8.2 for the Oracle DBA. The class will cover
Database Structure
Discuss the differences between DB2 UDB and Oracle RDBMS data structures.
Show what table spaces are created, when a DB2 UDB database is created.
Discuss the database configuration parameters and the difference that Oracle uses for INIT.ORA file.
Labs: Create the SAMPLE and a custom DB2 UDB database
Lecture 1: Command Line Processor
Lab: Using the DB2 Command Line Processor to examine instance and database configuration.
List the tables that exist for a database
Show the column characteristics for a table
Use the Graphical User Interface (GUI) to display database manager configuration parameters and database configuration parameters.
Lecture 2: Database Exploration
Understand the database structure: Table Spaces, tables, indexes and system catalog tables. Discuss Referential Integrity constraints.
Lab: Create the table spaces and tables using the DB2 Command Line Processor. Learn how to use script files to create database objects.
Use the Task Center (GUI) to schedule a job to create the table spaces. If this job is successful, execute a second script to create
tables. This exercise will demonstrate how to create and schedule jobs.
Use the Journal to see the results of a previously executed task.
Alter the tables and add the referential integrity.
Lecture 3: Populate the Database
Discussions on the Import and Load utilities. Discuss the differences between the two utilities.
Lab: Populate the tables created in the previous exercise using the LOAD utility.
Use the SET INTEGRITY command to correct the referential integrity constraint violations.
Lecture 4: Security
Discuss the basic security for DB2 UDB environment. Understand DB2 UDB uses group authority for SYSADM, SYSMAINT and SYSCTRL
authority. A new group in DB2 UDB V8.2 SYSMON has been added. Discuss the reasons that this group is used.
The students will discuss the GRANT and REVOKE authority commands. The implicit security will be discussed.
Lecture 5: Explain
Understand how to use the Visual and character explain tools to help in discovery of SQL statement performance problems.
Lab: Take an SQL statement and determine what might be incorrect with the database structure (index, Materialized Query Tables, etc..),
that is causing a performance problem.
Lecture 6: Automatic maintenance
DB2 UDB V8.2 allows for certain database maintenance be executed automatically. Learn how to have the RUNSTATS (update the table
statistics), REORG (reorganization of a table), and database backups to run automatically.
Lab: Using the Control Center (GUI) to set up a maintenance window and to have the REORG, RUNSTATS and database backup be
executed during this maintenance window.
Lecture 7: Recovery
Discussions on the two types of logging: Circular and Archival modes
Discussions on the two types of database backup: Offline and Online
Recovery modes: Full database recovery, Partial database recovery (table space) and recovery to a point in time
Database Configuration parameters that are used in recover will be discussed.
Lab: Backup a database. Recover the database to a point in time.
Lecture 8: Design Advisor
The Design Advisor is a tool, that will assist the DBA (Database Administrator) in designing the proper database structure.
Discuss how to capture SQL statements and run the SQL statements through the Design Advisor.
Lab: Take 3 complex SQL statements and run through the Design Advisor.
Take the results of the Design Advisor and place in the recommendations into the Task Center to run at a later time.
Execute the Design Advisor using the DB2 Command Line Processor.
Lecture 9: Health Center
The Health Center is a new GUI tool for DB2 UDB V8. The Health Center captures alerts and is designed to send the alert to
a user. Alerts can be set up by the DBA (Database Administrator) to be customize for a particular situation.
Lab: Modify the alter configuration parameters to capture warnings when a table space gets to be 60 percent full.
Modify the alter configuration parameters to capture errorss when a table space gets to be 70 percent full.
Update the database manager configuration file to start the Health monitor.
Lecture 10: Using the Activity Monitor
The Activity Monitor, which is new for DB2 UDB V8.2, monitors the dynamic SQL Statements. The lecture will discuss
dynamic versus static SQL statements. We will discuss how to capture SQL statements and generate reports.
Lab: Execute 3 script files that will run 3 SQL statements.
Use the Activity monitor to determine the slowest SQL statement.
Use the Activity monitor to Explain the SQL statement.
Run Statistics on the tables used by the SQL statement (SQL statement is a join) and Explain the SQL statement again
and notice the differences in the total cost to run the SQL Statement.
Create two new indexes and update the statistics on both tables. Run the Explain on the SQL statement and determine
if the performance was improved.
Lecture 11: Stored Procedures.
Discuss the differences between Oracle PL/SQL and DB2 UDB SQL/Procedure Langauge.
Show how to use the DB2 Development Center to create a simple stored procedure.
Learn several SQL/Procedure Language statements.
Discuss the structure of a Stored Procedure.
Learn how to run Stored Procedure Debugger.
Lab: Create a stored procedure, that will show how to build
Basic Stored Procedure Structure
Manage the SQLCODE and SQLSTATE variables
Code the basic EXIT HANDLERS when a row is NOT FOUND.
Define a CURSOR that will manage a result set.
Code a nested FOR LOOP.
Lecture 3: Populate the Database
Discussions on the Import and Load utilities. Discuss the differences between the two utilities.
Lab: Populate the tables created in the previous exercise using the LOAD utility.
Use the SET INTEGRITY command to correct the referential integrity constraint violations.
Lecture 4: Security
Discuss the basic security for DB2 UDB environment. Understand DB2 UDB uses group authority for SYSADM, SYSMAINT and SYSCTRL
authority. A new group in DB2 UDB V8.2 SYSMON has been added. Discuss the reasons that this group is used.
The students will discuss the GRANT and REVOKE authority commands. The implicit security will be discussed.
Lecture 5: Explain
Understand how to use the Visual and character explain tools to help in discovery of SQL statement performance problems.
Lab: Take an SQL statement and determine what might be incorrect with the database structure (index, Materialized Query Tables, etc..),
that is causing a performance problem.
Lecture 6: Automatic maintenance
DB2 UDB V8.2 allows for certain database maintenance be executed automatically. Learn how to have the RUNSTATS (update the table
statistics), REORG (reorganization of a table), and database backups to run automatically.
Lab: Using the Control Center (GUI) to set up a maintenance window and to have the REORG, RUNSTATS and database backup be
executed during this maintenance window.
Lecture 7: Recovery
Discussions on the two types of logging: Circular and Archival modes
Discussions on the two types of database backup: Offline and Online
Recovery modes: Full database recovery, Partial database recovery (table space) and recovery to a point in time
Database Configuration parameters that are used in recover will be discussed.
Lab: Backup a database. Recover the database to a point in time.
Lecture 8: Design Advisor
The Design Advisor is a tool, that will assist the DBA (Database Administrator) in designing the proper database structure.
Discuss how to capture SQL statements and run the SQL statements through the Design Advisor.
Lab: Take 3 complex SQL statements and run through the Design Advisor.
Take the results of the Design Advisor and place in the recommendations into the Task Center to run at a later time.
Execute the Design Advisor using the DB2 Command Line Processor.
Lecture 9: Health Center
The Health Center is a new GUI tool for DB2 UDB V8. The Health Center captures alerts and is designed to send the alert to
a user. Alerts can be set up by the DBA (Database Administrator) to be customize for a particular situation.
Lab: Modify the alter configuration parameters to capture warnings when a table space gets to be 60 percent full.
Modify the alter configuration parameters to capture errorss when a table space gets to be 70 percent full.
Update the database manager configuration file to start the Health monitor.
Lecture 10: Using the Activity Monitor
The Activity Monitor, which is new for DB2 UDB V8.2, monitors the dynamic SQL Statements. The lecture will discuss
dynamic versus static SQL statements. We will discuss how to capture SQL statements and generate reports.
Lab: Execute 3 script files that will run 3 SQL statements.
Use the Activity monitor to determine the slowest SQL statement.
Use the Activity monitor to Explain the SQL statement.
Run Statistics on the tables used by the SQL statement (SQL statement is a join) and Explain the SQL statement again
and notice the differences in the total cost to run the SQL Statement.
Create two new indexes and update the statistics on both tables. Run the Explain on the SQL statement and determine
if the performance was improved.
Lecture 11: Stored Procedures.
Discuss the differences between Oracle PL/SQL and DB2 UDB SQL/Procedure Langauge.
Show how to use the DB2 Development Center to create a simple stored procedure.
Learn several SQL/Procedure Language statements.
Discuss the structure of a Stored Procedure.
Learn how to run Stored Procedure Debugger.
Lab: Create a stored procedure, that will show how to build
Basic Stored Procedure Structure
Manage the SQLCODE and SQLSTATE variables
Code the basic EXIT HANDLERS when a row is NOT FOUND.
Define a CURSOR that will manage a result set.
Code a nested FOR LOOP.