October 2001
Beginner to intermediate
400 pages
7h 45m
English
PostgreSQL includes a number of conversion functions. These are used to convert from one data type to another and to format specific output styles.
The CAST function can be used to convert from one data type to another. Generally speaking, CAST is a fairly generic and easy-to-use function that makes most data-type conversions easy.
CAST(value AS newtype) value—The value that needs converting.
newtype—The new data type to convert to.
CAST('57' as INT)) → 57
CAST(57 as CHAR) → '57'
CAST(57 as NUMERIC(4,2)) → 57.00
CAST('05-23-87' as DATE)) → 1987-05-23 An additional way to perform type conversion is to separate the value and the desired data type with double colons (::).
Then ...
Read now
Unlock full access