On Db2 for z/OS, a database is not “the whole subsystem” and not the same as a schema. It is a logical container for table spaces, the tables that live in them, and their indexes. This page explains that container model, how database / table space / table fit together, and a simple CREATE DATABASE mental model.
IBM defines Db2 databases as a set of Db2 structures that include a collection of tables, their associated indexes, and the table spaces in which they reside. You define a database with CREATE DATABASE. Whenever a table space is created, it is assigned—explicitly or implicitly—to an existing database.
A single database can hold all the data for one application or a group of related applications. Collecting that data together lets you start or stop access as one operation and grant authorization patterns that treat the set as a unit. Authorized users can still access data across databases when privileges allow—databases organize management; they do not imprison SQL forever.
If you create a table space and do not specify a database name, the table space is created in the default database DSNDB04. If a table space is implicitly created and you omit IN on CREATE TABLE, Db2 can implicitly create a database for that table. Implicit names look like DSN00001, DSN00002, and so on. Sandboxes may rely on that; shared production usually prefers named databases your DBA standards recognize.
| Layer | Job |
|---|---|
| Database | Logical admin container for table spaces and index spaces |
| Table space | Page set storing table data (UTS: one table per space) |
| Table | Logical columns and rows queried with SQL |
| Index space / index | Separate structures for keys and access paths |
Application developers live at the table layer. Utilities and many operator commands care about table spaces and databases. When a DBA says “the PAYROLL database is stopped,” they mean access to the spaces in that database—not that the word PAYROLL disappeared from SQL dictionaries forever.
1234567891011121314CREATE DATABASE APPDB STOGROUP APPSTO BUFFERPOOL BP1 INDEXBP BP2; CREATE TABLESPACE EMPTS IN APPDB USING STOGROUP APPSTO PRIQTY 100 SECQTY 100 DEFINE YES; CREATE TABLE HR.EMPLOYEE ( EMPNO CHAR(6) NOT NULL, PRIMARY KEY (EMPNO) ) IN APPDB.EMPTS;
Read the stack bottom-up or top-down: APPDB contains EMPTS; EMPTS stores HR.EMPLOYEE’s data; SQL talks about HR.EMPLOYEE. Indexes on that table live in index spaces associated with the same database. Modern partition-by-growth and partition-by-range table spaces hold one table each. Deprecated multi-table segmented spaces still appear in older shops—know they exist, prefer current designs for new work.
IBM recommends minimizing the number of table spaces in each database. Too many spaces and tables in one database can hurt performance and manageability, increase contention, and grow log and maintenance cost. With UTS, “one table per table space” already pushes you toward more spaces—so spreading applications across thoughtfully named databases matters even more.
When you CREATE DATABASE, you name an eventual collection of tables, indexes, and table spaces. The name is an unqualified identifier up to eight characters and must be unique among databases.
1234CREATE DATABASE MYDB STOGROUP MYSTOGRP BUFFERPOOL BP8K4 INDEXBP BP4;
STOGROUP, BUFFERPOOL, and INDEXBP on CREATE DATABASE establish defaults you can override later on table space or index space definitions. Think of CREATE DATABASE as opening a labeled cabinet with default shelf rules—not as inserting rows.
| Reason | Detail |
|---|---|
| Operate as a unit | Start/stop/display status for related objects together |
| Limit contention | Some CREATE/ALTER/DROP and utility phases lock at database scope |
| Control DBD size | Large numbers of objects inflate database descriptors |
Put tables that are used and operated together in the same database. Avoid dumping unrelated high-churn DDL workloads into one giant database—some CREATE/ALTER/DROP activity and utility phases limit concurrent access to that database. Very large internal database descriptors (DBDs) are another reason to split: DBDs grow as objects are defined and do not shrink immediately when objects are dropped.
If CREATE TABLE omits IN, Db2 may create an implicit database named DSNxxxxx. If CREATE TABLESPACE omits a database, the space goes into DSNDB04. Both behaviors are legal; both can surprise you in shared systems when objects land somewhere operators did not expect. Prefer explicit IN database.tablespace once you leave personal sandboxes.
Operators use -START DATABASE, -STOP DATABASE, and -DISPLAY DATABASE style commands (exact syntax depends on your interface) to manage availability and see status. Developers rarely issue those daily, but knowing why databases exist explains outage windows and “database is stopped” tickets.
123456-- Application SQL still names tables, not the database: SELECT EMPNO, LASTNAME FROM HR.EMPLOYEE WHERE WORKDEPT = 'A00'; -- Placement was decided at CREATE time via IN APPDB.EMPTS
Think of a database as a labeled toy closet. Inside the closet are boxes (table spaces). Inside each modern box is one kind of toy set (a table). You play with the toys by name—“give me the red cars”—which is like SQL on tables. Grown-ups lock or open a whole closet at once when cleaning, which is like starting and stopping a database. The name sticker on the toys (schema) can say “Sam’s cars” even if the closet is labeled “Playroom.”
1. In Db2 for z/OS, a database is best described as:
2. What is DSNDB04?
3. Database vs table space vs table — which statement is true?
4. A practical reason to put related tables in one database is:
5. CREATE DATABASE names are: