How I can find out the foreign wrapper that a foreign table belongs to?
-
07-02-2021 - |
سؤال
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?
المحلول
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.
لا تنتمي إلى dba.stackexchange