Home > OS >  PostgreSQL: How can I check if table was created `WITH OIDS`?
PostgreSQL: How can I check if table was created `WITH OIDS`?

Time:12-07

I want to upgrade PostgreSQL database to new version of this database which doesn't support OIDS. Some of the tables was created with WITH OIDS. I think it was by default_with_oids setting. Is there information if table was created WITH OIDS in system schema tables information_schema.* or in system catalog tables pg_* or in other place?

CodePudding user response:

This is stored in pg_class.relhasoids

So to get all tables created with OIDs you can use something like:

select relnamespace::regnamespace::text as table_schema,
       relname as table_name
from pg_class
where relhasoids
  and relnamespace <> 'pg_catalog'::regnamespace;
  • Related