After creating a Timescale database, you're ready to create your first hypertable. Creating a hypertable is a two-step process:

  1. Create a PostgreSQL table as usual
  2. Convert it to a hypertable

You can also create distributed hypertables. For more information, see the distributed hypertables section.

To create a hypertable, you need to create a standard PostgreSQL table, and then convert it into a hypertable.

Hypertables are intended for time-series data, so your table needs a column that holds time values. This can be a timestamp, date, or integer.

  1. Create a standard PostgreSQL table:

    CREATE TABLE conditions (
    location TEXT NOT NULL,
    device TEXT NOT NULL,
    temperature DOUBLE PRECISION NULL,
  2. Convert the table to a hypertable. Specify the name of the table you want to convert, and the column that holds its time values.

    SELECT create_hypertable('conditions', 'time');

If your table already has data, you can migrate the data when creating the hypertable. Set the migrate_data argument to true when you call the create_hypertable function. This might take a long time if you have a lot of data. For more information about migrating data, see the data migration section.


Found an issue on this page?

Report an issue!