DB2 Datatypes
As shown below, DB2 supports a rich variety of datatypes, including most of the SQL2003 datatypes:
- BIGINT (SQL2003 Datatype: BIGINT)
Stores signed or unsigned integers between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807. Uses 8 bytes of storage.
- BLOB (SQL2003 Datatype: BLOB)
Holds variable-length binary data up to 2,147,483,647 bytes in length.
- CHAR(n), CHARACTER(n) (SQL2003 Datatype: CHARACTER(n))
Holds fixed-length character data up to 254 bytes in length. Uses (n) bytes of storage.
- CHAR(n) FOR BIT DATA (SQL2003 Datatype: none)
Holds a fixed number of values. Uses (n) bytes of storage.
- CLOB (SQL2003 Datatype: CLOB)
Holds variable-length character data up to 2,147,483,647 bytes in length.
- DATALINK(n) (SQL2003 Datatype: DATALINK)
Stores a link to a file external to the database. Uses n+54 bytes of storage.
- DATE (SQL2003 Datatype: DATE)
Holds a calendar date without time of day. Uses 4 bytes of storage.
- DBCLOB(n) (SQL2003 Datatype: NCLOB)
Holds variable-length double-byte character data up to 107,3741,823 characters in length.
- DEC(p,s), DECIMAL(p,s) (SQL2003 Datatype: DECIMAL, DECIMAL(p,s))
May have a precision of 1 to 31 and a scale of 0 to 31. Uses the integral part of (p/2)+1, where p is the precision bytes storage.
- DOUBLE, DOUBLE PRECISION (SQL2003 Datatype: DOUBLE PRECISION)
Holds floating point numbers of -1.79769E+308 through 1.79769E+308. Uses 8 bytes of storage.
- FLOAT (SQL2003 Datatype: FLOAT)
A synonym of DOUBLE PRECISION.
- FLOAT (p) (SQL2003 Datatype: ...
Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.