A wide range of data types are supported and can be used to declare variables in a PL/SQL block.
PL/SQL data type | DB2® SQL data type | Description |
---|---|---|
BINARY_INTEGER | INTEGER | Integer numeric data |
BLOB | BLOB (4096) | Binary data |
BLOB (n) | BLOB (n) |
Binary large object data |
BOOLEAN | BOOLEAN | Logical Boolean (true or false) |
CHAR | CHAR
(n) n = 63 if the string units of the environment is set to CODEUNITS32 n = 254 otherwise |
Fixed-length character string data of length n |
CHAR (n) | CHAR (n) |
Fixed-length character string data of length n |
CHAR (n CHAR) | CHAR (n CODEUNITS32 ) |
Fixed-length character string data of length n UTF-32 code units1 |
CHAR VARYING (n) | VARCHAR (n) | Variable-length character string data of maximum length n |
CHAR VARYING (n CHAR) | VARCHAR (n CODEUNITS32 ) |
Variable-length character string data of maximum length n UTF-32 code units1 |
CHARACTER | CHARACTER
(n) n = 63 if the string units of the environment is set to CODEUNITS32 n = 254 otherwise |
Fixed-length character string data of length n |
CHARACTER (n) | CHARACTER (n) |
Fixed-length character string data of length n |
CHARACTER (n CHAR) | CHARACTER
(n CODEUNITS32 ) n = 1 to 63 |
Fixed-length character string data of length n UTF-32 code units1 |
CHARACTER VARYING (n) | VARCHAR (n) |
Variable-length character string data of maximum length n |
CHARACTER VARYING (n CHAR) | VARCHAR (n CODEUNITS32 ) |
Variable-length character string data of maximum length n UTF-32 code units1 |
CLOB | CLOB (1M) | Character large object data |
CLOB (n) | CLOB (n) |
Character large object data of length n |
CLOB (n CHAR) | CLOB (n CODEUNITS32 ) |
Character large object string data of length n UTF-32 code units1 |
DATE | DATE 2 | Date and time data (expressed to the second) |
DEC | DEC (9, 2) | Decimal numeric data |
DEC (p) | DEC (p) |
Decimal numeric data of precision p |
DEC (p, s) | DEC (p, s) |
Decimal numeric data of precision p and scale s |
DECIMAL | DECIMAL (9, 2) | Decimal numeric data |
DECIMAL (p) | DECIMAL (p) |
Decimal numeric data of precision p |
DECIMAL (p, s) | DECIMAL (p, s) |
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) |
REAL | Real numeric data |
FLOAT (n) |
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 | NCHAR
(n) 3 n = 63 if the NCHAR_MAPPING configuration parameter is set to GRAPHIC_CU32 or CHAR_CU32 n = 127 otherwise |
Fixed-length national character string data of length n |
NCHAR (n) |
NCHAR (n) 3 | Fixed-length national character string data of length n |
NCLOB 4 | NCLOB(1M) 3 | National character large object data |
NCLOB (n) | NCLOB (n) 3 | National character large object data of maximum length n |
NVARCHAR2 | NVARCHAR 3 | Variable-length national character string data |
NVARCHAR2 (n) | NVARCHAR (n) 3 | Variable-length national character string data of maximum length n |
NUMBER | NUMBER 5 | Exact numeric data |
NUMBER (p) | NUMBER (p) 5 | Exact numeric data of maximum precision p |
NUMBER (p, s) | NUMBER (p, s) 5 |
Exact numeric data of maximum precision p and scale s |
NUMERIC | NUMERIC (9.2) | Exact numeric data |
NUMERIC (p) | NUMERIC (p) |
Exact numeric data of maximum precision p |
NUMERIC (p, s) | NUMERIC (p, s) |
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) |
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 |
VARCHAR (n) | VARCHAR (n) | Variable-length character string data with a maximum length of n |
VARCHAR (n CHAR) | VARCHAR (n CODEUNITS32 ) |
Variable-length character string data of maximum length n UTF-32 code units1 |
VARCHAR2 (n) | VARCHAR2 (n) 6 | Variable-length character string data with a maximum length of n |
VARCHAR2 (n CHAR) | VARCHAR2 (n CODEUNITS32 ) |
Variable-length character string data of maximum length n UTF-32 code units1 |
|
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.