postgresql 如何修复 Postgres 中的“错误:c.relhasoids 列不存在”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/58461178/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:30:19  来源:igfitidea点击:

How to fix "ERROR: column c.relhasoids does not exist" in Postgres?

postgresql

提问by Nao

I'm trying to CREATE TABLEcommand in Postgresql. After creating a table, if I punch in TABLEtable name, it works.

我正在尝试在 Postgresql 中创建 TABLE命令。创建表后,如果我打入TABLE table name,它就可以工作。

But I punch in \dtable name, I keep getting an error below.

但是我输入\d table name,我在下面不断收到错误消息。

ERROR: column c.relhasoids does not exist LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...

ERROR: column c.relhasoids does not exist LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...

I attempted DROP DATABASEtable namerecreated a database and recreated a table again several times. But it didn't work.

我尝试DROP DATABASE table name重新创建一个数据库并再次重新创建一个表。但它没有用。

Any suggestions would be appreciated! Thank you.

任何建议,将不胜感激!谢谢你。

回答by richyen

I am able to reproduce your error if I am using Postgres v.12 and an older client (v.11 or earlier):

如果我使用 Postgres v.12 和旧客户端(v.11 或更早版本),我可以重现您的错误:

[root@def /]# psql -h 172.17.0.3
psql (11.5, server 12.0)
WARNING: psql major version 11, server major version 12.
         Some psql features might not work.
Type "help" for help.

postgres=# create table mytable (id int, name text);
CREATE TABLE
postgres=# table mytable;
 id | name 
----+------
(0 rows)

postgres=# \d mytable;
ERROR:  column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...
                                                             ^
postgres=# 

This is because in v. 12, table OIDs are no longer treated as special columns, and hence the relhasoidscolumn is no longer necessary. Please make sure you're using a v. 12 psqlbinary so you don't encounter this error.

这是因为在第 12 版中,表 OID 不再被视为特殊列,因此relhasoids不再需要该列。请确保您使用的是 v. 12psql二进制文件,以免遇到此错误。

You may not necessarily be using psql, so the more general answer here is to make sure you're using a compatible client.

您可能不一定使用psql,因此这里更一般的答案是确保您使用兼容的客户端。

回答by joakim

For anyone running Postgresas a Dockercontainer:

对于将Postgres作为Docker容器运行的任何人:

Instead of running psqlfrom the host, run it from inside the container e.g.

不是从主机运行psql,而是从容器内部运行它,例如

docker exec -it postgres_container_name psql your_connection_string

The Postgresimage always ships with the corresponding—and thus always updated—version of psqlso you don't have to worry about having the correct version installed on the host machine.

Postgres的形象总是附带相应的,因而总是更新版本psql的,所以你不必担心有安装在主机上的正确版本。

回答by Manohar Reddy Poreddy

I had this issue today, was unable to continue work due to this, strangely the application code is working fine.

我今天遇到了这个问题,因此无法继续工作,奇怪的是应用程序代码工作正常。

Later, found this issue is only occurring if I use OmniDb client I use to connect to DB.

后来,发现这个问题只有在我使用我用来连接数据库的 OmniDb 客户端时才会发生。

I have switched client to default pgAdmin 4 that comes with postgres installation & issue is not occurring anymore pgAdmin 4. Link: https://www.pgadmin.org/download/pgadmin-4-windows/

我已将客户端切换到 postgres 安装附带的默认 pgAdmin 4 并且问题不再发生 pgAdmin 4。链接:https: //www.pgadmin.org/download/pgadmin-4-windows/

Its possible that OmniDb client might be older, but no time to troubleshoot it, using pgAdmin 4 for now.

OmniDb 客户端可能较旧,但没有时间对其进行故障排除,暂时使用 pgAdmin 4。

Hope that helps.

希望有帮助。

回答by Danilo Silva

I had the same issue today too. In my case, the problem was solved when I deleted the version 12 and installed the version 11. Seems that v12 has some features that must be create along the others columns.

我今天也有同样的问题。就我而言,当我删除版本 12 并安装版本 11 时,问题解决了。似乎 v12 有一些必须沿着其他列创建的功能。

回答by Bruno Machado

I had the same problem. But I found the solution by downloading the latest build on 14/10/2019 Follow the link: https://postbird.paxa.kuber.host/2019_10_14.06_42-master-7a9e949

我有同样的问题。但我通过在 14/10/2019 下载最新版本找到了解决方案,请点击链接:https: //postbird.paxa.kuber.host/2019_10_14.06_42-master-7a9e949

I hope it helps

我希望它有帮助