Combinations of data types that can be compared using comparison operators, BETWEEN, or IN are shown below.
Left side | Right side | ||
---|---|---|---|
Numeric type | Character string type | Date/time type | |
Numeric type | Y | N | N |
Character type | N | Y | N |
Date/time type | N | N | Y |
Y: Can be compared
N: Cannot be compared
When strings with different lengths are compared, the shorter one is padded with spaces to make the lengths match.
When numeric values with different precisions are compared, data will be converted to the type with the higher precision.
Set operation and CASE also follow the same rules.
Value expressions specified in operators will be converted to data types that are valid for that operator.
See
Refer to "Functions and Operators" under "The SQL Language" in the PostgreSQL Documentation for information on data types that can be specified in operators.