Contact us

Type Aliases

Type Aliases
bool boolean, bit
i8 int8, tinyint
i16 int16, smallint
i32 int32, integer, int
i64 int64, bigint
u8 uint8, tinyint unsigned
u16 uint16, smallint unsigned
u32 uint32, unsigned, integer unsigned, int unsigned
u64 uint64, bigint unsigned
f32 float32, single, float, real
f64 float64, double, double precision
ts timestamp
tp timeperiod, period
epoch unixepoch
i8range int8range, ri8, rint8
i16range int16range, ri16, rint16
i32range int32range, ri32, rint32
i64range int64range, ri64, rint64
u8range uint8range, ru8, ruint8
u16range uint16range, ru16, ruint16
u32range uint32range, ru32, ruint32
u64range uint64range, ru64, ruint64
f32range float32range, rf32, rfloat32
f64range float64range, rf64, rfloat64
tsrange timestamprange, rts, rtimestamp
epochrange unixepochrange, repoch, runixepoch
str string, text, varchar, char
bstr bstring, bytea, varbinary, binary, blob
symbol sym, symbol64, sym64
bsymbol bsym, bsymbol64, bsym64
line linestring
mpoint multipoint
mline multiline, mlinestring, multilinestring
mpolygon multipolygon
gpoint geopoint, geogpoint
gline geoline, geogline, glinestring, geolinestring, geoglinestring
gpolygon geopolygon, geogpolygon
gmpoint geompoint, geogmpoint, gmultipoint, geomultipoint, geogmultipoint
gmline gmlinestring, gmultiline, gmultilinestring, geomline, geomlinestring, geomultiline, geomultilinestring, geogmline, geogmlinestring, geogmultiline, geogmultilinestring
gmpolygon geompolygon, geogmpolygon, gmultipolygon, geomultipolygon, geogmultipolygon

Type Conversions


The following are tables showing all the type conversion available in the MSQL language.

From/To bool Integral Floating text binary Numeric range timestamp unixepoch timeperiod rtimestamp runixepoch Geometric Geographic
bool - - - explicit - - - - - - - - -
Integral - implicit1 implicit2 explicit - - explicit explicit explicit - - - -
Floating - implicit3 explicit - - explicit explicit explicit - - - -
text explicit explicit explicit - explicit4 - explicit explicit explicit explicit explicit explicit explicit
binary - - - explicit4 - - - - - - - explicit explicit
Numeric range - - - - - explicit5 - - - - - - -
timestamp - explicit explicit explicit - - - explicit6 - - - - -
unixepoch - explicit explicit explicit - - implicit6 - - - - - -
timeperiod - explicit explicit explicit - - - - - - - - -
rtimestamp - - - explicit - explicit - - - - explicit - -
runixepoch - - - explicit - explicit - - - explicit - - -
Geometric - - - explicit explicit - - - - - - - explicit7
Geographic - - - explicit explicit - - - - - - explicit7 -

[1]: In operator and function calls, all integral arguments are always implicitly upcasted to the int64 type.

[2]: In operator and function calls where floating-point arguments are expected, the integer arguments are also accepted and implicitly upcasted to float64.

[3]: In operator and function calls, all floating-point arguments are always implicitly upcasted to the float64 type.

[4]: Byte sequences are converted to/from their hexadecimal representation (e.g. a string of hexadecimal digits).

[5]: Refers to conversion between different range types.

[6]: In operator and function calls, unixepoch arguments are implicitly upcasted to the timestamp type.

[7]: Conversion is possible only between corresponding kinds of geometric and geographic objects (e.g. point <-> geogpoint, multipolygon <-> geogmultipolygon).

Implicit conversions are those which can happen without an explicit call to the CAST function or the :: operator.
Explicit conversions require explicit calls to the CAST function or the :: operator, e.g. CAST(123.45 AS text) or '2020-01-07 08:15:00'::timestamp. They are most often internally implemented as calls to special conversion functions such as TO_CHAR or ST_TOGEOM.


The following are special conversion functions for performing explicit casts between values of different types:

Type conversion Special conversion function(s)
bool -> text TO_CHAR
Numeric -> text TO_CHAR
text -> bool PARSE_BOOL
text -> Integral PARSE_INT
text -> Floating PARSE_FLOAT
text -> timestamp PARSE_TS
text -> unixepoch PARSE_EPOCH
text -> timeperiod PARSE_TP
text -> rtimeperiod PARSE_TSRANGE
text -> runixepoch PARSE_EPOCHRANGE
Temporal -> text TO_CHAR (temporal)
text -> binary HEX_DECODE, BASE64_DECODE
binary -> text HEX_ENCODE, BASE64_ENCODE
Geometry -> Geography ST_TOGEOG
Geography -> Geometry ST_TOGEOM
text -> Geometry ST_POINTFROMTEXT
ST_LINEFROMTEXT
ST_POLYGONFROMTEXT
ST_MPOINTFROMTEXT
ST_MLINEFROMTEXT
ST_MPOLYFROMTEXT
text -> Geography ST_GEOGPOINTFROMTEXT
ST_GEOGLINEFROMTEXT
ST_GEOGPOLYGONFROMTEXT
ST_GEOGMPOINTFROMTEXT
ST_GEOGMLINEFROMTEXT
ST_GEOGMPOLYFROMTEXT
Geometry -> text ST_ASTEXT
Geography -> text ST_ASTEXT
binary -> Geometry ST_POINTFROMWKB
ST_LINEFROMWKB
ST_POLYGONFROMWKB
ST_MPOINTFROMWKB
ST_MLINEFROMWKB
ST_MPOLYFROMWKB
binary -> Geography ST_GEOGPOINTFROMWKB
ST_GEOGLINEFROMWKB
ST_GEOGPOLYGONFROMWKB
ST_GEOGMPOINTFROMWKB
ST_GEOGMLINEFROMWKB
ST_GEOGMPOLYFROMWKB
Geometry -> binary ST_ASBINARY
Geography -> binary ST_ASBINARY