postgresql 数据库 timescaledb数据库 创建超表 遇见的的问题 报错
文章目录
前言
这几天对大量的旧表改为超表,记录遇到的问题
一 cannot create a unique index without the column “create_time” (used in partitioning)
报错详情
SELECT create_hypertable('hrmw.tb_cs', 'create_time', chunk_time_interval => INTERVAL '1 day')
> 错误: cannot create a unique index without the column "create_time" (used in partitioning)
解决方案
这个是因为你采用的的分区键(字段)不是唯一 把你的分区字段 改为主键 就可以了
二 DETAIL: It is not possible to turn temporary or unlogged tables into hypertables
报错详情
SELECT create_hypertable('tb_copy1', 'create_time', chunk_time_interval => INTERVAL '1 day')
> ERROR: table "tb_hrmw_moni_target_error_copy1" has to be logged
DETAIL: It is not possible to turn temporary or unlogged tables into hypertables.
解决方案
这是因为你建的表示不记录的,需要改一下表的选项
或者把建表语句的UNLOGGED 去掉
三 ERROR: invalid INSERT on the root table of hypertable “超表名”
HINT: Make sure the TimescaleDB extension has been preloaded.
报错详情
ERROR: invalid INSERT on the root table of hypertable “超表名”
HINT: Make sure the TimescaleDB extension has been preloaded.
解决方案
这个一般是还原出现的多 我建议是把数据备份 重新创建超表 数据备份解决办法