Oracle and DB2, Comparison and Compatibility/Storage Model/Data Types/DB2

From Wikibooks, open books for an open world
< Oracle and DB2, Comparison and Compatibility‎ | Storage Model‎ | Data Types
Jump to: navigation, search

DB2[edit]

Character Data Types
DB2 Character Data Types.png


If the length of the character data varies significantly, VARCHAR is more efficient because CHAR will pad the field with blanks to the length of CHAR(n). These blanks will be transmitted across the network. If the size of actual data does not vary much, CHAR is more efficient since each VARCHAR field has a few bytes of length information.

Numeric Data Types
DB2 Numeric Data Types.png
Date Data Types
DB2 Date Data Types.png


DB2 has a series of special registers that are storage areas that can be referenced in SQL statements. CURRENT TIMEZONE specifies the TIMEZONE parameter in the form of a time duration with a data type of DECIMAL(6,0) in the format HHMMSS. The time duration is derived by the instance that executes the SQL statement. To get the CURRENT TIME or CURRENT TIMESTAMP adjusted to GMT/UTC, subtract the CURRENT TIMEZONE register from the CURRENT TIME or TIMESTAMP.

The assumption is that the clock is set to local time and the TIMEZONE parameter is zero, or the clock is set to GMT and the TIMEZONE parameter gives the difference from GMT.

LOB Data Types
DB2 LOB Data Types.png
Graphic Data Types
DB2 Graphic Data Types.png


ROWID Data Type
DB2 ROWID data Types.png
XML Data Type
DB2 XML Data Types.png