Data type coercion chart
Conversion types
The following table defines all possible type conversions that Vertica supports. The data types in the first column of the table are the inputs to convert, while data types listed across the second heading row indicate the resultant assignments.
Data Types |
Conversion Types | ||||
---|---|---|---|---|---|
Implicit | Explicit | Assignment | Assignment without numeric meaning | Conversion without explicit casting | |
BOOLEAN |
|
||||
INTEGER |
|
|
|
||
NUMERIC |
FLOAT |
INTEGER |
|
NUMERIC | |
FLOAT |
|
|
|||
LONG VARCHAR |
|
|
LONG VARCHAR | ||
VARCHAR |
|
|
VARCHAR | ||
CHAR |
|
* |
CHAR | ||
TIMESTAMP |
TIMESTAMPTZ |
|
TIMESTAMP | ||
TIMESTAMPTZ |
TIMESTAMP |
|
TIMESTAMPTZ | ||
DATE |
TIMESTAMP |
|
|||
TIME |
TIMETZ |
|
|
TIME | |
TIMETZ |
|
|
TIMETZ | ||
INTERVAL DAY/SECOND |
TIME |
|
INTERVAL DAY/SECOND | ||
INTERVAL YEAR/MONTH |
|
INTERVAL YEAR/MONTH | |||
LONG VARBINARY |
VARBINARY |
LONG VARBINARY | |||
VARBINARY |
|
VARBINARY | |||
BINARY |
VARBINARY |
BINARY | |||
UUID |
|
UUID |
Implicit and explicit conversion
Vertica supports data type conversion of values without explicit casting, such as NUMERIC(10,6) -> NUMERIC(18,4)
.Implicit data type conversion occurs automatically when converting values of different, but compatible, types to the target column's data type. For example, when adding values, (INTEGER + NUMERIC
), the result is implicitly cast to a NUMERIC
type to accommodate the prominent type in the statement. Depending on the input data types, different precision and scale can occur.
An explicit type conversion must occur when the source data cannot be cast implicitly to the target column's data type.
Assignment conversion
In data assignment conversion, coercion implicitly occurs when values are assigned to database columns in an INSERT
or UPDATE...SET
statement. For example, in a statement that includes INSERT...VALUES('2.5')
, where the target column data type is NUMERIC(18,5)
, a cast from VARCHAR
to the column data type is inferred.
In an assignment without numeric meaning, the value is subject to CHAR/VARCHAR/LONG VARCHAR comparisons.