PGError:错误:关系列不存在

编程入门 行业动态 更新时间:2024-10-25 06:21:54
本文介绍了PGError:错误:关系列不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将列"isGroup"的值更改为值"public".

I'm trying to change the value of a column "isGroup" to the value "public".

我创建了一个迁移:

Post.connection.execute("update Posts set isgroup='public'")

但是,出现以下错误:

PGError: ERROR: column "isgroup" of relation "posts" does not exist

不幸的是,我在连接和执行迁移的同时运行了创建迁移的列.但是,"isGroup"列确实存在于Heroku上,因此很奇怪该列未显示为出现.

I had unfortunately ran the column creating migration at the same time as the connection.execute migration. However, the "isGroup" column does exist on Heroku, so it is weird that the column is not showing as appearing.

有什么建议吗?

推荐答案

如果您确定列isGroup存在,则应使用以下方式对其进行引用:

If you are sure that column isGroup exists, then you should quote it like:

UPDATE posts SET "isGroup" = 'public'

请注意,默认情况下,PostgreSQL会将所有未加引号的名称折叠成小写.

Note that PostgreSQL by default folds all unquoted named to lowercase.

为避免这种混淆和引用的必要性,您可能希望使用ALTER TABLE ... RENAME COLUMN ...将isGroup重命名为isgroup.

To avoid this confusion and necessity to quote, you might want to rename isGroup to isgroup using ALTER TABLE ... RENAME COLUMN ....

更多推荐

PGError:错误:关系列不存在

本文发布于:2023-10-14 11:54:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1490984.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不存在   错误   系列   PGError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!