postgresql 数据库 timescaledb数据库 创建超表 遇见的的问题 报错

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.

在这里插入图片描述
解决方案
这个一般是还原出现的多 我建议是把数据备份 重新创建超表 数据备份解决办法

猜你喜欢

转载自blog.csdn.net/yang_z_1/article/details/114288878