I'm trying to figure out how to get the schema of a table if I have the oid in Postgres 9.5.1. I tried using information_schema
but can't figure out which table I use to join with the oid
.
You need to join pg_namespace
to pg_class
select nsp.nspname as schema_name, tbl.relname as table_name
from pg_namespace nsp
join pg_class tbl on nsp.oid = tbl.relnamespace
where tbl.oid = 42;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With