TimescaleDB/CheatSheet

From Wiki

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