Module 3: DB2 Objects
Database
A database in DB2 is a collection of related physical and logical objects - tablespaces, tables, indexes and views. It is the top-level object in the DB2 object hierarchy.
What is a database
- A database groups the objects of one application together.
- One DB2 system can manage up to 64,000 separate databases.
- Recommended practice is one database per application.
- Tables are linked to a database with the IN DATABASE clause of CREATE TABLE or CREATE TABLESPACE.
Database and DBD
- Every database has a Data Base Descriptor (DBD) that stores descriptive and control information about all objects in the database.
- Each time an object is created, DB2 writes its definition into the DBD.
- The maximum size of a DBD is 2 GB, so do not overload one database with too many objects.
- When a plan is bound, DB2 locks the DBD of the databases the plan uses.
CREATE DATABASE - example
- Databases are created with the DDL statement CREATE DATABASE:-
CREATE DATABASE MMADBV BUFFERPOOL BP0 STOGROUP SG1;
- Here MMADBV is the database name, BP0 is the default bufferpool and SG1 is the default storage group for its tablespaces.
- A database is removed with DROP DATABASE MMADBV; - use it carefully, it drops everything inside.
