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

标签 database postgresql database-replication

我将 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/

相关文章:

database - 在 Firebase 中,有没有办法在不加载所有节点数据的情况下获取节点的子节点数?

mysql - 带 where = false 的 rails scope,在 heroku 上的工作方式不同

java - Postgres 如何创建一个在查询中使用的函数

database - 在 Ubuntu 上的 Oracle XE 下创建新数据库

python - 如何在sql中存储树结构?

database - 使用 amazon simpledb 匿名阅读

postgresql - Postgres:最新镜像上的Docker容器无法启动

mysql - RDS 数据库的本地副本

postgresql - Azure SQL 数据同步

sql - Oracle 流和物化 View 之间的区别