gpt4 book ai didi

database - 无法更新表临时表,因为它没有副本标识并在 Postgres 中发布更新

转载 作者:行者123 更新时间:2023-12-03 20:28:23 24 4
gpt4 key购买 nike

我将 Postgres 数据库与复制一起使用。
我在 postgres 函数中使用了临时表。我无法在通过加入更新临时表时更新它。

下面是 Postgres 查询(tempallergyupdates 是临时表):

 drop table if exists tempallergyupdates;
create temp table tempallergyupdates(patientallergyid int,updateid int, newupdateid int);
update tempallergyupdates set patientallergyid = 1;

上面的查询抛出以下异常:

cannot update table "tempallergyupdates" because it does not have a replica identity and publishes updates

最佳答案

我们刚刚遇到了这个并找到了解决方案。事实证明,PostgreSQL 不喜欢缺少涉及复制的主键的表,甚至是临时表。因此,要么在临时表中添加一个,要么在创建表后使用这样的语句:

ALTER TABLE table_name REPLICA IDENTITY FULL;

关于database - 无法更新表临时表,因为它没有副本标识并在 Postgres 中发布更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56000702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com