Cross Database Query in PostgreSQL
I have been using Postgres for the last few years and recently came across the use case of cross-database query. I am sharing the same and if you have the same kind of requirement you might it interesting. Before going into more details, let's go through a few basic differences between MySQL and PostgreSQL: A schema for both the DBMSs doesn't mean the same thing. MySQL : Synonymous to the database. Allows across database queries. For example, SELECT * FROM db1.table1 tb1 inner join db2.table2 tb2 on tb1.column1 = tb2.column PostgreSQL : A namespace within the database. By default, a database contains three schemas namely information_schema, pg_catalog, and public. In the public schema, all tables and views created by a user reside. Doesn't allow across database queries out of the box. Foreign data wrapper does the same job. Foreign Data Wrapper It provides a way to allow across database queries. NOTE: The following set of commands have ...