Goal Find all foreign tables.
Type General (Overview of some aspect of the database.)
License MIT License
Data Source INFORMATION_SCHEMA only
SQL Query
SELECT foreign_table_schema, 
foreign_table_name, 
foreign_server_name,
foreign_data_wrapper_name,
foreign_server_type AS fs_type,
foreign_server_version AS fs_version,
authorization_identifier AS foreign_server_owner,
string_agg(fso.option_name || ': ' || fso.option_value, ';
' ORDER BY fso.option_name) AS foreign_server_options, string_agg(fto.option_name || ': ' || fto.option_value, ';
' ORDER BY fto.option_name) AS foreign_table_options FROM INFORMATION_SCHEMA.foreign_tables INNER JOIN INFORMATION_SCHEMA.foreign_servers USING (foreign_server_name) LEFT JOIN INFORMATION_SCHEMA.foreign_server_options AS fso USING (foreign_server_name) LEFT JOIN INFORMATION_SCHEMA.foreign_table_options AS fto USING (foreign_table_schema, foreign_table_name) GROUP BY foreign_table_schema, foreign_table_name, foreign_server_name, foreign_data_wrapper_name, foreign_server_type, foreign_server_version, authorization_identifier ORDER BY foreign_server_name, foreign_table_schema, foreign_table_name;
Collections

This query belongs to the following collections:

NameDescription
Find problems by overviewQueries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .
Categories

This query is classified under the following categories:

NameDescription
Distributed databaseQueries of this category provide information about the foreign table mechanism.