Skip to main content

INSERT

INSERT INTO <table> (entity, ts, <channels...>) VALUES (...), (...), ...;

This page is the timeseries form. The verb changes meaning by family: on a rows table INSERT mints a new row and returns its xid (never an upsert); on a kv table INSERT is the upsert — (key, …) addresses, the same key overwrites.

  • entity (string) and ts (number, Unix milliseconds) are required columns
  • any subset of channels may appear — a fragment writes only what it carries
  • NULL in a value list means "this channel did not arrive" (nothing is written)
  • value types must match the channel declaration (number → f64, string → string; a BOOL channel takes only true/false/1/0, an INT channel only whole numbers)
-- full fragment
INSERT INTO telemetry (entity, ts, speed, status) VALUES
('veh-1', 1700000000000, 52.5, 'moving'),
('veh-2', 1700000001000, 12.0, 'idle');

-- partial fragment: only the event channel arrived
INSERT INTO telemetry (entity, ts, event) VALUES ('veh-1', 1700000030000, 'brake');

Updating mutable tables

There is no UPDATE statement: on a MUTABLE table, inserting the same entity with a newer ts is the update. Reads resolve to the newest version; the merge worker discards the rest.

INSERT INTO devices (entity, ts, name) VALUES ('d1', 1700000000000, 'old-name');
INSERT INTO devices (entity, ts, name) VALUES ('d1', 1700000060000, 'new-name');
SELECT name FROM devices WHERE entity = 'd1'; -- 'new-name'