refs:
https://docs.timescale.com/v1.2/getting-started/setup
大部分来着官方文档,请直接去官方网站查看,此处仅作个人记录。
1)在已经安装好postgresql数据库下安装扩展:
# Connect to PostgreSQL, using a superuser named 'postgres'
psql -U postgres -h localhost
-- Now create a new empty database (skip this if you already have a database):
-- Create the database, let's call it 'tutorial'
CREATE database tutorial;
-- Connect to the database
\c tutorial
-- Extend the database with TimescaleDB
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
2)转换旧的postgre表到hypetable,旧表必须有时间序列,且不重复的组合唯一键:
-- Assuming 'time' is the time column for the dataset
SELECT create_hypertable('new_table', 'time');
-- Insert everything from old_table
INSERT INTO new_table SELECT * FROM old_table;