Promotion of data types
Data types can be classified into groups of related data types. Within such groups, an order of precedence exists where one data type is considered to precede another data type. This precedence enables the database manager to support the promotion of one data type to another data type that appears later in the precedence ordering. For example, the data type CHAR can be promoted to VARCHAR; INTEGER can be promoted to DOUBLE PRECISION; but CLOB is NOT promotable VARCHAR.
The database manager considers the promotion of data types when:
- performing function resolution (see Function resolution)
- casting distinct types (see Casting between data types)
- assigning distinct types to built-in data types (see Distinct type comparisons)
For each data type, Table 1 shows the precedence list (in order) that the database manager uses to determine the data types to which each data type can be promoted. The table indicates that the best choice is the same data type and not promotion to another data type. Note that the table also shows data types that are considered equivalent during the promotion process. For example, CHARACTER and GRAPHIC are considered to be equivalent data types.
Data Type | Data Type Precedence List (in best-to-worst order) |
---|---|
SMALLINT | SMALLINT, INTEGER, BIGINT, decimal, real, double, DECFLOAT |
INTEGER | INTEGER, BIGINT, decimal, real, double, DECFLOAT |
BIGINT | BIGINT, decimal, real, double, DECFLOAT |
decimal | decimal, real, double, DECFLOAT |
real | real, double, DECFLOAT |
double | double, DECFLOAT |
DECFLOAT | DECFLOAT |
CHAR or GRAPHIC | CHAR or GRAPHIC, VARCHAR or VARGRAPHIC, CLOB or DBCLOB |
VARCHAR or VARGRAPHIC | VARCHAR or VARGRAPHIC, CLOB or DBCLOB |
CLOB or DBCLOB | CLOB or DBCLOB |
CHAR FOR BIT DATA | CHAR, VARCHAR, CLOB, BINARY, VARBINARY, BLOB |
VARCHAR FOR BIT DATA | VARCHAR, CLOB, VARBINARY, BLOB |
BINARY | BINARY, VARBINARY, BLOB, CHAR FOR BIT DATA, VARCHAR FOR BIT DATA |
VARBINARY | VARBINARY, BLOB, VARCHAR FOR BIT DATA |
BLOB | BLOB |
DATE | DATE, TIMESTAMP |
TIME | TIME |
TIMESTAMP | TIMESTAMP |
DATALINK | DATALINK |
ROWID | ROWID |
XML | XML |
ARRAY | ARRAY |
udt | same udt |
Note:
The lower case
types above are defined as follows:
Shorter and longer form synonyms of the data types listed are considered to be the same as the synonym listed. Character and graphic strings are only compatible for Unicode data. |