Columns that hold megabytes of text, images, or XML documents cannot always live comfortably beside a 10-byte status code on the same base page. Db2 for z/OS stores LOB and XML data in specialized spaces while still letting SQL treat them as ordinary columns. This page introduces that storage model for beginners.
From an application view, you declare a column as BLOB, CLOB, DBCLOB, or XML, then INSERT and SELECT it. From a storage view, Db2 usually keeps the bulky payload in separate table spaces tied to the base table. That split protects base-row density, improves how utilities and buffer pools can be tuned, and still presents one logical table to SQL.
| Type | Meaning |
|---|---|
| BLOB | Binary large object — images, PDFs, opaque bytes |
| CLOB | Character large object — big text documents |
| DBCLOB | Double-byte character large object — graphic/large DBCS text |
| XML | Native XML documents with pureXML storage and functions |
Inline LOB options and version-specific limits exist—small LOBs can sometimes live closer to the base row—but the mental model to learn first is: base table for control and regular columns, auxiliary/XML spaces for the heavy data. When something goes wrong with space or COPY, DBAs look at those related objects, not only the base table space name you use in everyday talk.
A table may contain a LOB column, yet the actual LOB data is usually stored in another table called an auxiliary table. That auxiliary table lives in a LOB table space. One auxiliary table must exist for each LOB column (and partitioned designs multiply the pattern per partition rules). The base table includes a ROWID column that Db2 uses to locate data in the auxiliary table. The auxiliary table must have exactly one index—the auxiliary index—typically keyed for that ROWID linkage.
| Piece | Role |
|---|---|
| Base table | Holds non-LOB columns plus ROWID / LOB indicators |
| LOB table space | Special table space type for LOB data |
| Auxiliary table | Stores the actual LOB bytes for one LOB column (per rules) |
| Auxiliary index | Required index enabling fast LOB lookup via ROWID |
123456789101112CREATE TABLE HR.EMP_DOCS ( EMPNO CHAR(6) NOT NULL, DOC_ID INTEGER NOT NULL, RESUME CLOB(10M), PHOTO BLOB(5M), PRIMARY KEY (EMPNO, DOC_ID) ) IN APPDB.EMPDOC_TS; -- Db2 often creates LOB table spaces, auxiliary tables, -- and auxiliary indexes implicitly for RESUME and PHOTO. -- In some cases you CREATE LOB TABLESPACE / AUXILIARY TABLE -- / INDEX explicitly in the same database as the base table.
For many modern table space designs, defining a LOB column is enough: Db2 implicitly creates the LOB table space, auxiliary table, and auxiliary index. Explicit creation is required in certain situations—classic examples involve specific partitioned layouts where you must create one LOB table space and auxiliary table per partition for each LOB column. When explicit, you use CREATE LOB TABLESPACE, CREATE AUXILIARY TABLE, and CREATE INDEX, keeping LOB spaces in the same database as the base table.
Application programmers usually do not name auxiliary tables in SELECT lists. They host-variable a CLOB or use LOB locators so they can work with pieces of a large value without always materializing everything in program storage. Host-language details belong in later data-type pages; the storage takeaway is that SQL names the base column, while Db2 navigates ROWID to auxiliary pages behind the scenes.
pureXML is Db2 for z/OS support for storing and querying XML. The XML column type holds documents. To manage XML efficiently alongside traditional SQL types, Db2 stores XML data in separate table spaces from the base table that contains the XML column. The underlying mechanism is transparent to applications: you do not pick the XML table space name on every INSERT.
When you create an XML column, Db2 implicitly creates an XML table space, an XML table to store the data, and related identifiers such as a node ID used internally. Each XML column gets its own table space. For partitioned bases, XML data is associated with the corresponding base partition. XML table spaces also have their own index spaces when indexes are defined—IBM notes that utility implications resemble the LOB story because large data again lives outside the base space.
12345678CREATE TABLE SALES.ORDER_XML ( ORDER_ID BIGINT NOT NULL, ORDER_DOC XML, PRIMARY KEY (ORDER_ID) ) IN SALESDB.ORDXML_TS; -- Applications insert XML into ORDER_DOC. -- Db2 maintains XML table space objects behind the scenes.
Do not store XML “only as a CLOB” if you need pureXML features—and do not assume a BLOB is queryable as structured XML. Choose the type that matches how you will use the data.
| Topic | Tip |
|---|---|
| Space growth | Plan DASD for auxiliary/XML spaces—often larger than base tables |
| Buffer pools | Large object pages may deserve separate buffer pool strategy |
| Utilities | Include related LOB/XML spaces in backup and REORG planning |
| Application fetch | Use locators or careful SELECT lists so you do not drag huge values needlessly |
LOB and XML columns change operational cost even when SQL looks simple. Image copies must cover related spaces. REORG and CHECK utilities need correct scope. Recovering a base table space without its LOB/XML companions leaves logical wreckage. Buffer pool sizing may isolate large object pages from high-churn transactional pages so a flood of document fetches does not evict hot index leaf pages.
On the application side, SELECT * that pulls multi-megabyte CLOBs in an online transaction is a self-inflicted outage pattern. Project only the columns you need; use locators or progressive chunking patterns when working with huge values; and avoid logging surprises by understanding whether a LOB table space is logged and how your utility strategy handles it.
12345678910111213Logical table HR.EMP_DOCS | +-- base table space pages: EMPNO, DOC_ID, ROWID, indicators | +-- LOB table space(s): auxiliary table for RESUME (CLOB) | +-- LOB table space(s): auxiliary table for PHOTO (BLOB) Logical table SALES.ORDER_XML | +-- base table space pages: ORDER_ID + XML column control | +-- XML table space: document storage for ORDER_DOC
Imagine each employee row is a folder on a shelf. The folder holds a small card with the employee number (ordinary columns). The thick photo album and the long life-story book do not fit in the folder, so they go in labeled crates in the back room (LOB or XML spaces). A sticker on the folder (ROWID / linkage) tells Db2 which crate belongs to which card. You still ask for “Sam’s photo” by name, but the librarian walks to the back room to fetch the heavy book.
1. Where does most LOB column data live in Db2 for z/OS?
2. What does the base table’s ROWID help Db2 do for LOBs?
3. When you add an XML column, Db2 typically:
4. From an application SQL perspective, LOB and XML columns are:
5. Why do utilities treat LOB/XML specially?