将 Postgres 9.6 继承表迁移到 TimeScaleDB
Migrate Postgres 9.6 Inherited Tables to TimeScaleDB
我们有一个时间序列 table,它通过继承进行分区。我们现在想将其迁移到同一数据库中的 TimeScaleDB。文档说要么使用 pg_dump/COPY 要么使用 LIKE 创建。我们都无法使用继承的 tables。我们是否应该 pg_dump/COPY 将所有继承的 table 放入 CSV 文件中,连接然后导入?
CREATE TABLE events (
date TIMESTAMP,
event SMALLINT
);
CREATE TABLE events_2018_1 (
CHECK (date >= '2018-01-01 00:00:00' AND date < '2018-02-01 00:00:00')
)
INHERITS (events);
CREATE INDEX idx_events_date
ON events
USING BTREE (date);
此处介绍了在同一数据库中迁移数据的最简单方法:http://docs.timescale.com/latest/getting-started/migrating-data#same-db
基本上你创建一个新的超表然后 运行 INSERT INTO new_table SELECT * FROM old_table;
如果您有任何问题,请告诉我。
我们有一个时间序列 table,它通过继承进行分区。我们现在想将其迁移到同一数据库中的 TimeScaleDB。文档说要么使用 pg_dump/COPY 要么使用 LIKE 创建。我们都无法使用继承的 tables。我们是否应该 pg_dump/COPY 将所有继承的 table 放入 CSV 文件中,连接然后导入?
CREATE TABLE events (
date TIMESTAMP,
event SMALLINT
);
CREATE TABLE events_2018_1 (
CHECK (date >= '2018-01-01 00:00:00' AND date < '2018-02-01 00:00:00')
)
INHERITS (events);
CREATE INDEX idx_events_date
ON events
USING BTREE (date);
此处介绍了在同一数据库中迁移数据的最简单方法:http://docs.timescale.com/latest/getting-started/migrating-data#same-db
基本上你创建一个新的超表然后 运行 INSERT INTO new_table SELECT * FROM old_table;
如果您有任何问题,请告诉我。