1. MooseStack
  2. Data Types
  3. Integer Types

On this page

Signed IntegersUnsigned IntegersType Mapping ReferenceSee Also

Integer Types

ClickHouse provides signed (Int) and unsigned (UInt) integers in various sizes. Choose the smallest type that fits your data range for optimal storage efficiency.

Signed Integers

import { Int8, Int16, Int32, Int64 } from "@514labs/moose-lib"; interface Metrics {  small_value: Int8;      // Int8: -128 to 127  medium_value: Int16;    // Int16: -32,768 to 32,767  user_id: Int32;         // Int32: -2.1B to 2.1B  big_value: Int64;       // Int64: -9.2E18 to 9.2E18}

You can also use the verbose syntax:

import { ClickHouseInt } from "@514labs/moose-lib"; interface MetricsVerbose {  user_id: number & ClickHouseInt<"int32">;  big_value: number & ClickHouseInt<"int64">;}

Unsigned Integers

import { UInt8, UInt16, UInt32, UInt64 } from "@514labs/moose-lib"; interface Counters {  flags: UInt8;           // UInt8: 0 to 255  port: UInt16;           // UInt16: 0 to 65,535  count: UInt32;          // UInt32: 0 to 4.2B  total: UInt64;          // UInt64: 0 to 18.4E18}

Type Mapping Reference

ClickHouse TypeTypeScript HelperTypeScript VerbosePythonRange
Int8Int8
number & ClickHouseInt<"int8">
Annotated[int, "int8"]
-128 to 127
Int16Int16number & ClickHouseInt<"int16">Annotated[int, "int16"]-32,768 to 32,767
Int32Int32number & ClickHouseInt<"int32">Annotated[int, "int32"]-2.1B to 2.1B
Int64Int64number & ClickHouseInt<"int64">Annotated[int, "int64"]±9.2×10¹⁸
UInt8UInt8number & ClickHouseInt<"uint8">Annotated[int, "uint8"]0 to 255
UInt16UInt16number & ClickHouseInt<"uint16">Annotated[int, "uint16"]0 to 65,535
UInt32UInt32number & ClickHouseInt<"uint32">Annotated[int, "uint32"]0 to 4.2B
UInt64UInt64number & ClickHouseInt<"uint64">Annotated[int, "uint64"]0 to 18.4×10¹⁸
Choosing the right size

Use the smallest integer type that fits your data. For example, use UInt8 for values 0-255 (like status codes), UInt16 for ports, and Int32 for most IDs. This reduces storage and improves cache efficiency.

See Also

  • Floats — Floating-point types for approximate numbers
  • Decimals — Fixed-point precision for financial data
  • Overview
  • Quick Start
  • Templates / Examples
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
MooseStack in your App
  • App / API frameworks
Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
  • Moose APIs
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
    • Strings
    • LowCardinality
    • Integers
    • Floats
    • Decimals
    • Booleans
    • Date & Time
    • Network
    • Arrays
    • Maps
    • Nested
    • Tuples
    • Enums
    • Geometry
    • JSON
    • Nullable
    • Aggregates
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Changelog
Contribution
  • Documentation
  • Framework
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplates
Changelog
Source506