PostgreSQL Enterprise (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Foreign Data Wrappers (FDW): Querying Across Databases.
senior LevelCode ExampleDatabases & SQL
In Simple Words:
PostgreSQL supports the SQL/MED (Management of External Data) standard via Foreign Data Wrappers (postgres_fdw). It allows querying remote PostgreSQL instances, MySQL databases, Redis, or CSV files directly as if they were local tables, supporting cross-database joins and push-down predicates!
sql
CREATE EXTENSION postgres_fdw;
CREATE SERVER remote_billing FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '10.0.1.5', dbname 'billing_db', port '5432');