Summary:
See also: Data Types.
The runtime system performs data conversion implicitly without objection, as long as the data conversion is valid. For example, when you assign a number expression to a character variable, the runtime system converts the resulting number to a literal string.
Conversion rules apply to variable assignment, function parameters, and returned values.
The following table shows which pairs of data types are compatible.
Columns represent source data types and lines represent receiving data types. |
||||||||||||||
char | varchar | string | integer | smallint | float | smallfloat | decimal | money | date | datetime | interval | text | byte | |
char | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1, 8 | 1, 9 | 1 | 1 | 15 | 15 |
varchar | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1, 8 | 1, 9 | 1 | 1 | 15 | 15 |
string | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1, 8 | 1, 9 | 1 | 1 | 15 | 15 |
integer | 2, 3 | 2, 3 | 2, 3 | 3, 4 | 3, 4 | 3, 4 | 3, 4 | 11 | 15 | 15 | 15 | 15 | ||
smallint | 2, 3 | 2, 3 | 2, 3 | 3 | 3, 4 | 3, 4 | 3, 4 | 3, 4 | 3, 11 | 15 | 15 | 15 | 15 | |
float | 2, 3, 5 | 2, 3, 5 | 2, 3, 5 | 10 | 10 | 3 | 3 | 11 | 15 | 15 | 15 | 15 | ||
smallfloat | 2, 3, 5 | 2, 3, 5 | 2, 3, 5 | 5, 10 | 10 | 5 | 3, 5 | 3, 5 | 5, 11 | 15 | 15 | 15 | 15 | |
decimal | 2, 3, 6 | 2, 3, 6 | 2, 3, 6 | 3 | 3 | 3, 6 | 3, 6 | 3, 6 | 3, 6 | 3, 11 | 15 | 15 | 15 | 15 |
money | 2, 3, 6 | 2, 3, 6 | 2, 3, 6 | 3 | 3 | 3, 6 | 3, 6 | 3, 6 | 3, 6 | 3, 11 | 15 | 15 | 15 | 15 |
date | 2 | 2 | 2 | 11 | 11 | 3,4,11 | 3,4,11 | 3,4,11 | 3,4,11 | 12, 14 | 15 | 15 | 15 | |
datetime | 2 | 2 | 2 | 15 | 15 | 15 | 15 | 15 | 15 | 13, 14 | 7, 14 | 15 | 15 | 15 |
interval | 2 | 2 | 2 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 3, 7 | 15 | 15 |
text | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | |
byte | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 | 15 |