1

I have found that the following query lists all my foreign tables in my PostgreSQL database:

select * from information_schema."tables" where table_type='FOREIGN TABLE';

Now I want to find out the foreign wrapper connection that a database is referred into. In this answer the following query lists all my foreign wrappers:

SELECT fdw.fdwname AS "Name",
  pg_catalog.pg_get_userbyid(fdw.fdwowner) AS "Owner",
  fdw.fdwhandler::pg_catalog.regproc AS "Handler",
  fdw.fdwvalidator::pg_catalog.regproc AS "Validator"
FROM pg_catalog.pg_foreign_data_wrapper fdw
ORDER BY 1;

Now what I want is to find out how to combine this information in order to find out in which foreign wrapper a foreign table belongs into. Do you have any idea how to query that?

3

This should do the trick:

SELECT
  foreign_table_name,
  foreign_server_name

FROM
  information_schema.foreign_tables

You may find more information on information_schema.foreign_tables in the documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.