Contact us

Boolean


0|1 BOOL

Standard SQL boolean type. Can take one of three values: true, false or unknown, the latter being represented by the SQL null value.

It is most often used as a result of comparisons and other predicates.

MSQL doesn't allow implicit casting of other types to bool in contexts which expect boolean values, such as CASE expressions, WHERE and HAVING clauses etc.
Only explicitly boolean-valued expressions (i.e. having the bool return type) are allowed there.

bool values cannot be stored into SpaceTime tables. int8 or uint8 data types should be used instead.


Numeric


INT & UINT

Signed and unsigned integer values.

Name Storage size (bytes) Description Value range Aliases
i8 1 Smallest integer type -128 to +127 int8, tinyint
i16 2 Small integer type, equivalent of shortin C/C++ -32,768 to +32,767 int16, smallint
i32 4 Most common integer type, best choice for storage in most cases -2,147,483,648 to +2,147,483,647 int32, int, integer
i64 8 Largest integer type, used by default for all computations, also useful for storing very large values that don't fit into i32 -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 int64, bigint
u8 1 Smallest unsigned integer type 0 to +255 uint8, tinyint unsigned
u16 2 Small unsigned integer type, equivalent of unsigned short in C/C++ 0 to +65,535 uint16, smallint unsigned
u32 4 Most common unsigned integer type, best choice for storage in most cases when unsigned values are needed 0 to +4,294,967,295 uint32, unsigned, int unsigned, integer unsigned
u64 8 Largest unsigned integer type, used for storing very large values that don't fit into u32 0 to +18,446,744,073,709,551,615 uint64, bigint unsigned

Any computation dealing with integers automatically upcasts values to i64 in order to avoid possible overflows.

Therefore, integers smaller than i64 should primarily be used for storage to reduce record size on disk (if the value range allows it).
Likewise, unsigned types should also only be used for storage to double the range of possible values stored for the same record size (if it's known they'll always be non-negative).


FLOAT

Single and double-precision floating-point numbers.

Name Storage size (bytes) Description Value range Aliases
f32 4 Single-precision floating-point number (~6 significant digits) ± 1.175 E-38 to ± 3.403 E+38 float32, float, single, real
f64 8 Double-precision floating-point number (~15 significant digits) ± 2.225 E-308 to ± 1.798 E+308 float64, double, double precision

Any computation dealing with floating-point numbers automatically upcasts values to the float64 type.
This also applies to operations where one operand is a floating-point number, and the other an integer.

Note that there are no fixed-point numeric types (DECIMAL, NUMERIC) available, just use f64 instead.


Time Points


TIMESTAMP | TS

A type representing a single point in time (e.g. 2020-03-25 08:15:00.000) with a sub-second precision (less than 1us).

A timestamp value is internally stored in a timezone-independent way as a f64 floating-point number, representing the fractional number of seconds passed since the Unix epoch (i.e. 1970-01-01 00:00:00).

When doing timezone-aware manipulations with timestamp values (such as converting to string, extracting the hour of the day, adding months/years, etc.), the timestamp value is treated as belonging to the default time zone set for the current session (the session-default time zone can be changed using the SET statement). But all such operations allow for overriding the session-default time zone, and using another time zone for that specific operation (e.g. TS_EXTRACT('day', t, 'America/Los_Angeles')).


UNIXEPOCH | EPOCH

A type representing a single point in time (e.g. 2020-03-25 08:15:00.000) with a precision of one second.

A unixepoch value is internally stored in a timezone-independent way as an u32 integer, representing the number of seconds passed since the Unix epoch (i.e. 1970-01-01 00:00:00).

The range of possible unixepoch values is (in the GMT timezone) '1970-01-01 00:00:00' - '2106-02-07 06:28:15'.

Any computation with unixepoch values (e.g. invoking temporal functions or operators) will upcast them beforehand to the regular ts type, and the result (depending on the operation) will also be a regular timestamp value.

The epoch type is meant to be used only for storage in the cases where millisecond precision (the precision of regular ts type) isn't needed, to reduce record size on the disk (epoch is 4 bytes, ts is 8 bytes) and consequently to improve performance.


Time Periods


TIMEPERIOD | TP

A type representing a difference between two time points or a floating time interval (e.g. 3 hours or 7.5 days).

A timeperiod value is internally stored as a signed f64 floating-point number, representing a duration of the time period in seconds.