DB2 Version 10.1 for Linux, UNIX, and Windows

Data types (PL/SQL)

The DB2® data server supports a wide range of data types that can be used to declare variables in a PL/SQL block.

Table 1. Supported scalar data types that are available in PL/SQL
PL/SQL data type DB2 SQL data type Description
BINARY_INTEGER INTEGER Integer numeric data
BLOB BLOB (4096) Binary data
BLOB (n)

BLOB (n)
n = 1 to 2 147 483 647

Binary large object data
BOOLEAN BOOLEAN Logical Boolean (true or false)
CHAR CHAR (1) Fixed-length character string data of length 1
CHAR (n)

CHAR (n)
n = 1 to 254

Fixed-length character string data of length n
CHAR VARYING (n) VARCHAR (n) Variable-length character string data of maximum length n
CHARACTER CHARACTER (1) Fixed-length character string data of length 1
CHARACTER (n)

CHARACTER (n)
n = 1 to 254

Fixed-length character string data of length n
CHARACTER VARYING (n)

VARCHAR (n)
n = 1 to 32 672

Variable-length character string data of maximum length n
CLOB CLOB (1M) Character large object data
CLOB (n)

CLOB (n)
n = 1 to 2 147 483 647

Fixed-length long character string data of length n
DATE DATE 1 Date and time data (expressed to the second)
DEC DEC (9, 2) Decimal numeric data
DEC (p)

DEC (p)
p = 1 to 31

Decimal numeric data of precision p
DEC (p, s)

DEC (p, s)
p = 1 to 31; s = 1 to 31

Decimal numeric data of precision p and scale s
DECIMAL DECIMAL (9, 2) Decimal numeric data
DECIMAL (p)

DECIMAL (p)
p = 1 to 31

Decimal numeric data of precision p
DECIMAL (p, s)

DECIMAL (p, s)
p = 1 to 31; s = 1 to 31

Decimal numeric data of precision p and scale s
DOUBLE DOUBLE Double precision floating-point number
DOUBLE PRECISION DOUBLE PRECISION Double precision floating-point number
FLOAT FLOAT Float numeric data

FLOAT (n)
n = 1 to 24

REAL Real numeric data

FLOAT (n)
n = 25 to 53

DOUBLE Double numeric data
INT INT Signed four-byte integer numeric data
INTEGER INTEGER Signed four-byte integer numeric data
LONG CLOB (32760) Character large object data
LONG RAW BLOB (32760) Binary large object data
LONG VARCHAR CLOB (32760) Character large object data
NATURAL INTEGER Signed four-byte integer numeric data
NCHAR GRAPHIC (127) Fixed-length graphic string data

NCHAR (n)
n = 1 to 2000

GRAPHIC (n)
n = 1 to 127

Fixed-length graphic string data of length n
NCLOB 2 DBCLOB (1M) Double-byte character large object data
NCLOB (n) DBCLOB (2000) Double-byte long character string data of maximum length n
NVARCHAR2 VARGRAPHIC (2048) Variable-length graphic string data
NVARCHAR2 (n) VARGRAPHIC (n) Variable-length graphic string data of maximum length n
NUMBER NUMBER 3 Exact numeric data
NUMBER (p) NUMBER (p) 3 Exact numeric data of maximum precision p
NUMBER (p, s)

NUMBER (p, s) 3
p = 1 to 31

Exact numeric data of maximum precision p and scale s
NUMERIC NUMERIC (9.2) Exact numeric data
NUMERIC (p)

NUMERIC (p)
p = 1 to 31

Exact numeric data of maximum precision p
NUMERIC (p, s)

NUMERIC (p, s)
p = 1 to 31; s = 0 to 31

Exact numeric data of maximum precision p and scale s
PLS_INTEGER INTEGER Integer numeric data
RAW BLOB (32767) Binary large object data
RAW (n)

BLOB (n)
n = 1 to 32 767

Binary large object data
SMALLINT SMALLINT Signed two-byte integer data
TIMESTAMP (0) TIMESTAMP (0) Date data with timestamp information
TIMESTAMP (p) TIMESTAMP (p) Date and time data with optional fractional seconds and precision p
VARCHAR VARCHAR (4096) Variable-length character string data with a maximum length of 4096 characters
VARCHAR (n) VARCHAR (n) Variable-length character string data with a maximum length of n characters
VARCHAR2 (n) VARCHAR2 (n) 4 Variable-length character string data with a maximum length of n characters
  1. When the DB2_COMPATIBILITY_VECTOR registry variable is set for the DATE data type, DATE is equivalent to TIMESTAMP (0).
  2. For restrictions on the NCLOB data type in certain database environments, see "Restrictions on PL/SQL support".
  3. This data type is supported when the number_compat database configuration parameter set to ON.
  4. This data type is supported when the varchar2_compat database configuration parameter set to ON.

In addition to the scalar data types described in Table 1, the DB2 data server also supports collection types, record types, and REF CURSOR types.