I’m trying to CREATE TABLE command in Postgresql.
After creating a table, if I punch in TABLE table name, it works.
But I punch in d table name, I keep getting an error below.
ERROR: column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...
I attempted DROP DATABASE table name recreated a database and recreated a table again several times. But it didn’t work.
Any suggestions would be appreciated! Thank you.
asked Oct 19, 2019 at 6:39
![]()
NaoNao
1,2732 gold badges6 silver badges8 bronze badges
4
I am able to reproduce your error if I am using Postgres v.12 and an older client (v.11 or earlier):
[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 relhasoids column is no longer necessary. Please make sure you’re using a v. 12 psql binary so you don’t encounter this error.
You may not necessarily be using psql, so the more general answer here is to make sure you’re using a compatible client.
answered Oct 19, 2019 at 7:19
![]()
richyenrichyen
7,5263 gold badges12 silver badges28 bronze badges
2
For anyone running Postgres as a Docker container:
Instead of running psql from the host, run it from inside the container e.g.
docker exec -it postgres_container_name psql your_connection_string
The Postgres image always ships with the corresponding—and thus always updated—version of psql so you don’t have to worry about having the correct version installed on the host machine.
answered Nov 7, 2019 at 11:52
![]()
joakimjoakim
3,1332 gold badges23 silver badges25 bronze badges
6
If you’re using DataGrip, there’s an easy fix:
Try using «Introspect using JDBC metadata». This fixed it for me when (I think) I had a version mismatch between postgresql server and DataGrip client.
Under your connection settings -> Options tab -> check Introspect using JDBC metadata
According to https://www.jetbrains.com/help/datagrip/data-sources-and-drivers-dialog.html#optionsTab :
Switch to the JDBC-based introspector.
To retrieve information about database objects (DB metadata), DataGrip
uses the following introspectors:
A native introspector (might be unavailable for certain DBMS). The
native introspector uses DBMS-specific tables and views as a source of
metadata. It can retrieve DBMS-specific details and produce a more
precise picture of database objects.A JDBC-based introspector (available for all the DBMS). The JDBC-based
introspector uses the metadata provided by the JDBC driver. It can
retrieve only standard information about database objects and their
properties.Consider using the JDBC-based intorspector when the native
introspector fails or is not available.The native introspector can fail, when your database server version is
older than the minimum version supported by DataGrip.You can try to switch to the JDBC-based introspector to fix problems
with retrieving the database structure information from your database.
For example, when the schemas that exist in your database or database
objects below the schema level are not shown in the Database tool
window.
answered Nov 20, 2020 at 16:25
![]()
David HempyDavid Hempy
4,8712 gold badges42 silver badges63 bronze badges
2
The issue is the client (psql) is a different version from the postgres server. I have seen this issue with psql version 11 talking to postgres version 12. To solve this issue upgrade the psql version to 12.
If you are running a docker postgres, you can exec into the container then use the psql client installed there.
# get the container id with this
docker ps
# Then exec into the container, please note the host will now be 120.0.0.1
docker exec -it c12e8c6b8eb5 /bin/bash
answered Jul 16, 2020 at 16:08
![]()
EutychusEutychus
3938 silver badges10 bronze badges
I had this issue because my psql was 9.2 and the server version was 12.7.
So … clearly the psql client needs to be updated. But how?
Before you go downloading/installing anything though you may already have the right version. In my case I did.
I executed which psql which showed my version was coming from /usr/bin/psql.
I then checked /usr/pgsql-12/bin and found there was a psql in there.
So all I needed to do was ensure psql was picked up from there.
There are a number of places that could be controlling this; in my case I just added this line to my .pgsql_profile (in the postgres user’s home directory):
export PATH="/usr/pgsql-12/bin:$PATH"
Logging out and back in as postgres and executing which psql showed the change had been successful:
which psql
/usr/pgsql-12/bin/psql
answered Jul 30, 2021 at 11:51
JL_SOJL_SO
1,6221 gold badge23 silver badges34 bronze badges
This answer is specific to pgcli
If you are using pgcli you may be encountering this issue. It’s solved by updating the python package pgspecial.
If you installed pgcli using pip, you can simply do, depending on your python version:
pip install -U pgspecial
or
pip3 install -U pgspecial
If you are using Ubuntu and intalled pgcli using apt, you can either switch it to pip with:
sudo apt remove --purge pgcli
pip3 install pgcli
or update the distribution package python-pgspecial or python3-pgspecial from the Ubuntu packages web site. In that case you may need to update its dependencies as well.
answered Oct 25, 2020 at 10:28
![]()
JocelynJocelyn
1,31211 silver badges20 bronze badges
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.
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/
Its possible that OmniDb client might be older, but no time to troubleshoot it, using pgAdmin 4 for now.
Hope that helps.
answered Oct 19, 2019 at 9:32
![]()
1
Just update DataGrip solved this issue, Datagrip updated to version DataGrip 2019.3.3, Build #DB-193.6494.42, built on February 12, 2020, Now working 🙂
Just for DataGrip users!
answered Oct 2, 2020 at 17:10
![]()
DariusVDariusV
2,53314 silver badges21 bronze badges
1
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.
answered Oct 20, 2019 at 0:23
1
To fix this, edit Postgres.php file and comment the lines from hasObjectID function as shown below.
function hasObjectID($table) {
$c_schema = $this->_schema;
$this->clean($c_schema);
$this->clean($table);
/*
$sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}'
AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')";
$rs = $this->selectSet($sql);
if ($rs->recordCount() != 1) return null;
else {
$rs->fields['relhasoids'] = $this->phpBool($rs->fields['relhasoids']);
return $rs->fields['relhasoids'];
}
*/
}
answered Jun 20, 2020 at 6:15
![]()
Pankaj ShindePankaj Shinde
3,1732 gold badges35 silver badges43 bronze badges
I had the same issue when using PgAdmin to query the database.
Once I installed the newest version of PgAdmin the error disappeared!
answered Sep 13, 2020 at 17:19
![]()
You might also try restarting pgadmin.
After upgrading from postgres96 to postgres12 I had the same issue. My pgadmin was running psql v12.0 so that wasn’t the issue. I restarted pgadmin for a separate issue and the relhasoids issue went away.
If anyone could explain to me why this worked that would be appreciated.
answered Dec 16, 2021 at 18:43
answered Jul 16, 2020 at 4:01
![]()
OscarOscar
471 silver badge7 bronze badges
I also got same issue with my postgresql tables. I have fixed this issue by below query.
ALTER Table MyDataBase.table_name add column column_name data_type default 0 not null;
commit;
![]()
Suraj Rao
29.3k11 gold badges96 silver badges103 bronze badges
answered Nov 25, 2020 at 7:20
![]()
I facing the below error many times in the log file for PostgreSQL server v12.5 even the client version is the same version and I haven’t any other versions now. I just was having 10 and 12.5 and I removed both of them then I reinstalled v 12.5 only. any suggestions please ?
[23939] ERROR: column c.relhasoids does not exist at character 245
2021-02-20 20:03:02.274 EET [23939] STATEMENT: select n.nspname, c.relname, a.attname, a.atttypid, t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), case t.typtype when ‘d’ then t.typbasetype else 0 end, t.typtypmod, c.relhasoids, attidentity, c.relhassubclass from (((pg_catalog.pg_class c inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace and c.oid = 350213) inner join pg_catalog.pg_attribute a on (not a.attisdropped) and a.attnum > 0 and a.attrelid = c.oid) inner join pg_catalog.pg_type t on t.oid = a.atttypid) left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum order by n.nspname, c.relname, attnum
I facing the below error many times in the log file for PostgreSQL server v12.5 even the client version is the same version and I haven’t any other versions now. I just was having 10 and 12.5 and I removed both of them then I reinstalled v 12.5 only. any suggestions please ?
[23939] ERROR: column c.relhasoids does not exist at character 245
2021-02-20 20:03:02.274 EET [23939] STATEMENT: select n.nspname, c.relname, a.attname, a.atttypid, t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), case t.typtype when ‘d’ then t.typbasetype else 0 end, t.typtypmod, c.relhasoids, attidentity, c.relhassubclass from (((pg_catalog.pg_class c inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace and c.oid = 350213) inner join pg_catalog.pg_attribute a on (not a.attisdropped) and a.attnum > 0 and a.attrelid = c.oid) inner join pg_catalog.pg_type t on t.oid = a.atttypid) left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum order by n.nspname, c.relname, attnum
Google Translate
SEARCH
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
Archives
Archives
Blog Stats
- 1,151,001 hits
Categories
Meta
I get the following error when trying to select rows from a table:
ERROR: column rel.relhasoids does not exist
LINE 1: SELECT rel.relhasoids AS has_oids
Configuration is:
- Linux RHL8
- NAME=»Red Hat Enterprise Linux»
- VERSION=»8.2 (Ootpa)»
- postgresql12-server-12.3
- psql (12.3)
- PgAdmin 4.3 en 4,5
![]()
Laurenz Albe
38.5k4 gold badges34 silver badges58 bronze badges
asked Jul 14, 2020 at 13:20
The column relhasoids has been dropped from the system catalog pg_class in PostgreSQL v12, because the long deprecated WITH OIDS clause has been removed from CREATE TABLE.
Obviously you are using an old version of pgAdmin 4 that has not got the message yet.
Upgrade to a newer version of pgAdmin, and the error should vanish.
answered Jul 14, 2020 at 15:24
![]()
Laurenz AlbeLaurenz Albe
38.5k4 gold badges34 silver badges58 bronze badges