The DB2® data server supports a wide range of data types that 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 (1) | Fixed-length character string data of length 1 |
CHAR (n) | CHAR (n) |
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) |
Fixed-length character string data of length n |
CHARACTER VARYING (n) | VARCHAR (n) |
Variable-length character string data of maximum length n |
CLOB | CLOB (1M) | Character large object data |
CLOB (n) | CLOB (n) |
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) |
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 | GRAPHIC (127) | Fixed-length graphic string data |
NCHAR (n) |
GRAPHIC (n) |
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 |
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 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 |
|
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.