The tables in this section show valid assignments and comparisons between Derby data types.
Sorting and ordering of character data is controlled by the collation specified for a database when it is created, as well as the locale of the database. For details, see collation=collation attribute and territory=ll_CC attribute, as well as the sections "Creating a database with locale-based collation", "Creating a case-insensitive database", and "Character-based collation in Derby" in the Derby Developer's Guide.
The following table displays valid assignments between data types in Derby. A "Y" indicates that the assignment is valid.
Types | B |
S |
I |
B |
D |
R |
D |
F |
C |
V |
L |
C |
V |
L |
C |
B |
D |
T |
T |
X |
U |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BOOLEAN | Y | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
SMALLINT | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
INTEGER | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
BIGINT | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
DECIMAL | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
REAL | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
DOUBLE | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
FLOAT | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
CHAR | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | Y | Y | Y | - | - |
VARCHAR | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | Y | Y | Y | - | - |
LONG VARCHAR | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | - | - | - | - | - |
CHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | - | - | - | - |
VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | - | - | - | - |
LONG VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | - | - | - | - |
CLOB | - | - | - | - | - | - | - | - | Y | Y | Y | - | - | - | Y | - | - | - | - | - | - |
BLOB | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | Y | - | - | - | - | - |
DATE | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | - | - | - | - |
TIME | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | Y | - | - | - |
TIMESTAMP | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | - | Y | - | - |
XML | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | Y | - |
User-defined type | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | Y |
A value of a user-defined type can be assigned to a value of any supertype of that user-defined type. However, no explicit casts of user-defined types are allowed.
The following table displays valid comparisons between data types in Derby. A "Y" indicates that the comparison is allowed.
Types | B |
S |
I |
B |
D |
R |
D |
F |
C |
V |
L |
C |
V |
L |
C |
B |
D |
T |
T |
X |
U |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BOOLEAN | Y | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
SMALLINT | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
INTEGER | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
BIGINT | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
DECIMAL | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
REAL | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
DOUBLE | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
FLOAT | - | Y | Y | Y | Y | Y | Y | Y | - | - | - | - | - | - | - | - | - | - | - | - | - |
CHAR | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | Y | Y | - | - |
VARCHAR | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | Y | Y | - | - |
LONG VARCHAR | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
CHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | - |
VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | - |
LONG VARCHAR FOR BIT DATA | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
CLOB | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
BLOB | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
DATE | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | Y | - | - | - | - |
TIME | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | Y | - | - | - |
TIMESTAMP | - | - | - | - | - | - | - | - | Y | Y | - | - | - | - | - | - | - | - | Y | - | - |
XML | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
User-defined type | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |