I have a few foreign data wrappers set up from my main PostgreSQL database to other databases. Is there a table I can query to list all of the FDWs? Unfortunately select * from information_schema.schemata
doesn't give any hints about which schemas are foreign and which are local.
PostgreSQL – Listing Active Foreign Data Wrappers
foreign-datapostgresql
Related Question
- PostgreSQL – Using Foreign Data Wrapper for Query-Based Tables
- PostgreSQL – Creating Materialized Views from Foreign Tables
- PostgreSQL – How to Find Foreign Wrapper for a Foreign Table
- PostgreSQL – Feasibility of Thousands of Foreign Data Wrappers
- PostgreSQL FDW – How to Create Shared User Mapping in Foreign Data Wrapper Server
Best Answer
The information you're looking for is in various pg_catalog tables.
pg_class
is the main table that represents all relations, normal or foreign; you can limit it to foreign tables by includingWHERE relkind='f'
. Information on the foreign data wrappers themselves is inpg_foreign_data_wrappers
, on servers inpg_foreign_servers
, and on foreign tables inpg_foreign_tables
.Start with
select relname from pg_class where relkind='f'
to just get a list of table names, and from there you can use the pg_catalog docs to find whatever other pieces of information you need for what you're trying to do.