Skip to content

Int and UInt ​

CoordinatorDB provides signed (Int) and unsigned (UInt) integers from 8 through 256 bits. Use a width that contains the values your column must accept. Unsigned types reject negative values.

Syntax ​

text
Int8 | Int16 | Int32 | Int64 | Int128 | Int256
UInt8 | UInt16 | UInt32 | UInt64 | UInt128 | UInt256

Integer Ranges ​

A signed N-bit integer ranges from -2^(N-1) through 2^(N-1)-1. An unsigned N-bit integer ranges from 0 through 2^N-1.

Type Minimum Maximum
Int8 -128 127
Int16 -32768 32767
Int32 -2147483648 2147483647
Int64 -9223372036854775808 9223372036854775807
Int128 -170141183460469231731687303715884105728 170141183460469231731687303715884105727
Int256 -57896044618658097711785492504343953926634992332820282019728792003956564819968 57896044618658097711785492504343953926634992332820282019728792003956564819967
UInt8 0 255
UInt16 0 65535
UInt32 0 4294967295
UInt64 0 18446744073709551615
UInt128 0 340282366920938463463374607431768211455
UInt256 0 115792089237316195423570985008687907853269984665640564039457584007913129639935

Conversion and overflow ​

Inserts, updates, casts, defaults and generated expressions must fit the declared range. Out-of-range conversion raises NUMERIC_OVERFLOW; values do not wrap around. Fractional numeric input truncates toward zero before range checking.

Use quoted decimal text for wide values when the calling language or a JSON client cannot preserve a large integer exactly. Native wide integers support exact numeric operations; the legacy INTEGER declaration instead follows SQLite-style affinity.

A top-level column accepts SQL NULL unless it declares NOT NULL.

Examples ​

Creating a typed counter ​

sql
CREATE TABLE counters(id UInt32 PRIMARY KEY, attempts UInt8 NOT NULL);
INSERT INTO counters VALUES (1, 255);
sql
SELECT id, attempts
FROM counters
FORMAT csv;
text
1,255

An attempt to store 256 in attempts raises NUMERIC_OVERFLOW.

Converting a wide unsigned value ​

sql
SELECT CAST('18446744073709551615' AS UInt64),
       CAST('340282366920938463463374607431768211455' AS UInt128)
FORMAT csv;
text
18446744073709551615,340282366920938463463374607431768211455

Truncating fractional input ​

sql
SELECT CAST(12.9 AS Int8), CAST(-12.9 AS Int8)
FORMAT csv;
text
12,-12

See Decimal for exact fractional values and floating-point types for approximate values.