Name
CAST — Force a type conversion
Syntax
Description
The CAST operator forces the cast expression to the
datatype described by type name. The actual representation
(integer, real, text, BLOB) will be derived from the type name
by searching (case-insensitively) for these specific substrings.
The first string that matches will determine the type. If no
matches are found, the cast expression will be converted into
the most appropriate numeric value.
| Substring | Datatype |
|---|---|
| INT | Integer |
| CHAR | Text |
| CLOB | Text |
| TEXT | Text |
| BLOB | BLOB |
| REAL | Float |
| FLOA | Float |
| DOUB | Float |
Note that the type string
FLOATING POINT will be
interpreted as an integer, and not a real, since the first
substring listed will match the INT at the end of the name. This first entry
takes precedence over subsequent substrings, resulting in an
unexpected cast. It is best to use somewhat standard database
types to ensure correct conversion.
Once a specific datatype has been determined, the actual conversion is done using the standard rules. See Table 7-1 for specifics.
See Also
CREATE TABLE [SQL Cmd, Ap C]
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access