FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplatesGuides
Release Notes
Source514
  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

from typing import Annotated class Metrics(BaseModel):    small_value: Annotated[int, "int8"]     # Int8    medium_value: Annotated[int, "int16"]   # Int16    user_id: Annotated[int, "int32"]        # Int32    big_value: Annotated[int, "int64"]      # Int64

Unsigned Integers

from typing import Annotated class Counters(BaseModel):    flags: Annotated[int, "uint8"]      # UInt8    port: Annotated[int, "uint16"]      # UInt16    count: Annotated[int, "uint32"]     # UInt32    total: Annotated[int, "uint64"]     # UInt64

Type Mapping Reference

ClickHouse TypeTypeScript HelperTypeScript VerbosePythonRange
Int8
Int8
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
Build a New App
  • 5 Minute Quickstart
  • Browse Templates
  • Existing ClickHouse
Add to Existing App
  • Next.js
  • Fastify
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
Moose Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
  • Moose APIs & Web Apps
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
  • Release Notes
Contribution
  • Documentation
  • Framework