Integer

Tinybird supports various fixed-length integer data types, which can be either signed (Int) or unsigned (UInt). These types are used to store whole numbers within specific ranges, optimizing storage and performance based on the magnitude of the numbers you need to represent.

Int ranges

Signed integer types can store both positive and negative whole numbers, including zero.

  • Int8: [-128 : 127]
  • Int16: [-32768 : 32767]
  • Int32: [-2147483648 : 2147483647]
  • Int64: [-9223372036854775808 : 9223372036854775807]
  • Int128: [-170141183460469231731687303715884105728 : 170141183460469231731687303715884105727]
  • Int256: [-57896044618658097711785492504343953926634992332820282019728792003956564819968 : 57896044618658097711785492504343953926634992332820282019728792003956564819967]

Aliases:

  • Int8: TINYINT, INT1, BYTE, TINYINT SIGNED, INT1 SIGNED.
  • Int16: SMALLINT, SMALLINT SIGNED.
  • Int32: INT, INTEGER, MEDIUMINT, MEDIUMINT SIGNED, INT SIGNED, INTEGER SIGNED.
  • Int64: BIGINT, SIGNED, BIGINT SIGNED, TIME.

Example

This example casts a floating-point number to an Int32.

SELECT CAST(123.45 AS Int32) AS my_int_value

Result:

┌─my_int_value─┐
│          123 │
└──────────────┘

UInt ranges

Unsigned integer types can only store non-negative whole numbers (zero and positive numbers).

  • UInt8: [0 : 255]
  • UInt16: [0 : 65535]
  • UInt32: [0 : 4294967295]
  • UInt64: [0 : 18446744073709551615]
  • UInt128: [0 : 340282366920938463463374607431768211455]
  • UInt256: [0 : 115792089237316195423570985008687907853269984665640564039457584007913129639935]

Aliases:

  • UInt8: TINYINT UNSIGNED, INT1 UNSIGNED.
  • UInt16: SMALLINT UNSIGNED.
  • UInt32: MEDIUMINT UNSIGNED, INT UNSIGNED, INTEGER UNSIGNED
  • UInt64: UNSIGNED, BIGINT UNSIGNED, BIT, SET

Example

This example casts a positive floating-point number to a UInt32.

SELECT CAST(4294967295.99 AS UInt32) AS my_uint_value

Result:

┌─my_uint_value─┐
│    4294967295 │
└───────────────┘
Updated