SQL types mapping: IBM DB2 LUW
Original data types | DB2 data types |
---|---|
CHAR(n) |
CHAR(n) or NCHAR(n) (see note 1) |
VARCHAR(n[,m]) |
VARCHAR(n) or NVARCHAR(n) (see
note 1) |
LVARCHAR(n) |
VARCHAR(n) or NVARCHAR(n) (see
note 1) |
NCHAR(n) |
NCHAR(n) (synonym! see note 1) |
NVARCHAR(n[,m]) |
NVARCHAR(n[,m]) (synonym! note 1) |
BOOLEAN |
BOOLEAN (CHAR(1) with DB2 <
11.1) |
SMALLINT |
SMALLINT |
INTEGER |
INTEGER |
BIGINT |
BIGINT |
INT8 |
BIGINT |
SERIAL[(start)] |
INTEGER (see note 2) |
BIGSERIAL[(start)] |
BIGINT (see note 2) |
SERIAL8[(start)] |
BIGINT (see note 2) |
DOUBLE PRECISION / FLOAT[(n)] |
FLOAT[(n)] / DOUBLE |
REAL / SMALLFLOAT |
REAL |
DECIMAL(p,s) |
DECIMAL(p,s) (max is 31 digits) |
DECIMAL(p) with p<=15 |
DECFLOAT(16) |
DECIMAL(p) with p>15 |
DECFLOAT(16) if p=16,
DECFLOAT(34) if p>16 |
DECIMAL |
DECFLOAT(34) |
MONEY(p,s) |
DECIMAL(p,s) (max is 31 digits) |
MONEY(p) |
DECIMAL(p,2) (max is 31 digits) |
MONEY |
DECIMAL(16,2) |
DATE |
DATE |
DATETIME HOUR TO MINUTE |
TIME |
DATETIME HOUR TO SECOND |
TIME |
DATETIME HOUR TO FRACTION(n) |
TIMESTAMP (for fraction storage) |
DATETIME YEAR TO MONTH |
TIMESTAMP |
DATETIME YEAR TO DAY |
TIMESTAMP |
DATETIME YEAR TO HOUR |
TIMESTAMP |
DATETIME YEAR TO MINUTE |
TIMESTAMP |
DATETIME YEAR TO SECOND |
TIMESTAMP |
DATETIME YEAR TO FRACTION(n) |
TIMESTAMP |
INTERVAL q1 TO q2 |
CHAR(50) |
TEXT |
CLOB or NCLOB (see note 3) |
BYTE |
BLOB (see note 3) |
Notes:
- For character data types, see CHAR and VARCHAR data types
- For serial emulation, see SERIAL and BIGSERIAL data types.
- For LOB data types, see TEXT and BYTE (LOB) types.