Sie sind auf Seite 1von 9

10 Minute PPT on DB2 LOB (Large

Object Data)
Sunil Kumar S
Wipro Technologies

What are Large Objects


Large objects are a new set of DB2 data types that can store strings up to 2GB.
LOBs can be used to store audio, video, images, and other files that are larger

than 32 KB(VARCHAR).
Three types
BLOB Binary Large Object

- Pictures, voice, and mixed media. .

CLOB Character Large Object

- Documents that contain single

character set.
Double Byte Character Large Object - Documents that use a DBCS character

set.

Creation of large objects


Define a column of the appropriate LOB type

Mention the ROWID ( or DB2 will create it for you)

Create a table space and table to hold the LOB data.

Create an index on the auxiliary table.

Single LOB column table space


LOB Table Space

Base Tablespace
EMPLOYEE (Base Table)
Name

EMP _ID

XXXX

4356

YYYY

3456

Picture
1

Auxiliary
Table

PHOTO

Picture
2

Multiple LOB column table space

LOB Table Space 2

Base Tablespace
Movie
1

Base table
Col1

Col2

Data1

Data2

Data3

Data4

Col3

Auxiliary
Table

Col4

Movie
2

Picture
1

Auxiliary
Table

LOB Table Space 1


Picture
2

LOB Structure

Catalog Description of Base Table

LOB Indicator

Consists of
2-byte length field
2-byte flag
2-byte string containing the number of the currently stored version of the LOB.

LOB Example

CREATE TABLE
EMP_PHOTO_RESUME
(
EMPLOYEE_NAME VARCHAR NOT NULL,
EMPLOYEE_NUMBER INTEGER,
EMP_RESUME
CLOB(10 M) NULL
)
CREATE LOB TABLESPACE RESUMETS
IN MYDB
LOG NO;

CREATE AUXILIARY TABLE EMP_RESUME_TAB


IN MYDB.RESUMETS
STORES EMP_PHOTO_RESUME
COLUMN EMP_RESUME;
CREATE UNIQUE INDEX XEMP_RESUME
ON EMP_RESUME_TAB;
COMMIT;

Das könnte Ihnen auch gefallen