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 spellings | Stored as |
|---|---|
DOUBLE, FLOAT8, F64, REAL | f64 |
TEXT, STRING, VARCHAR, SYMBOL | string |
BOOL, BOOLEAN | f64 (semantic bool) |
INT, INTEGER, I64, BIGINT, INT8 | f64 (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 readsFILL NONE— event channel; never filled (default)STALENESS 60 s— withHOLD: held values older than this read asnull; defaultINFINITE
Table options
WITH (MUTABLE)— last-write-wins per entity,DELETEallowed, no retentionWITH (RETENTION 90 d)— immutable table: day-partitions older than the window are droppedWITH (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);