TimescaleDB/CheatSheet

From Wiki
Revision as of 10:06, 1 June 2024 by Marcluer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Howto

  • Create table
CREATE TABLE "metrics"(
    created timestamp with time zone default now() not null,
    type_id integer                                not null,
    value   double precision                       not null
);
  • Set table as hypertable
SELECT create_hypertable('metrics', by_range('created'));


PostgreSQL data types

  • boolean
  • char(n)
  • varchar(n)
  • text
  • smallint (-32768 - 32767)
  • int
  • serial (~auto_increment in mysql)
  • float(n)
  • real / float8
  • numeric(p,s)
  • date
  • time
  • timestamp
  • timestamptz
  • interval
  • json
  • jsonb
  • uuid
  • + special