Skip to main content

CREATE TABLE

CREATE TABLE <name> (
<channel> <TYPE> [FILL HOLD|NONE] [STALENESS <duration>|INFINITE],
...
) [WITH (MUTABLE | RETENTION <duration> [, ENTITY UUID])];

This declares a timeseries table — the first of the three families (rows and kv have their own DDL). entity and ts are implicit on every timeseries table and cannot be declared. The schema is not set in stone: columns can be added, tuned, renamed and dropped later with ALTER TABLE.

Types

Accepted spellingsStored as
DOUBLE, FLOAT8, F64, REALf64
TEXT, STRING, VARCHAR, SYMBOLstring
BOOL, BOOLEANf64 (semantic bool)
INT, INTEGER, I64, BIGINT, INT8f64 (semantic int)

Anything else (JSONB, arrays, timestamps-as-types...) is rejected: the type system is frozen at f64 + string.

BOOL does not break that freeze — it is a catalog-level 0/1 view over f64. Writes accept true/false/1/0 and reject anything else; reads surface real booleans (t/f over pg-wire, true/false in JSON). Storage cost is negligible: the Gorilla/XOR encoding stores an unchanged value in one bit, so a digital signal costs ~1 bit per sample.

INT is the same idea for whole numbers: writes reject fractional values, reads surface real integers (int8 over pg-wire, no .0 in JSON). An f64 holds integers exactly up to 2⁵³, far beyond any counter or code this engine will meet; declare INT for the intent and the clean rendering, not for range.

Channel attributes

  • FILL HOLD — state channel; last value carries forward on reads
  • FILL NONE — event channel; never filled (default)
  • STALENESS 60 s — with HOLD: held values older than this read as null; default INFINITE

Table options

  • WITH (MUTABLE) — last-write-wins per entity, DELETE allowed, no retention
  • WITH (RETENTION 90 d) — immutable table: day-partitions older than the window are dropped
  • WITH (ENTITY UUID) — the wall: writes whose entity is not a UUID are refused; register devices in a rows table and use its engine-generated id as the entity

MUTABLE and RETENTION are mutually exclusive.

For registries and other current-state data, see CREATE ROWS TABLE — the second table family.

Examples

CREATE TABLE telemetry (
speed DOUBLE FILL HOLD STALENESS 60 s,
status TEXT FILL HOLD,
event TEXT FILL NONE
) WITH (RETENTION 90 d);

CREATE TABLE positions (lat DOUBLE, lon DOUBLE) WITH (MUTABLE, ENTITY UUID);