I have two PostgreSQL databases connected over dblink extension. I want to create synonym for a table in first database so the queries that are coming through application I can route them to the table in the second database. It will be good to mention that both databases has the same structure.

Is it possible to create a synonym or is there any alternative way to do so?


That's exactly what foreign data wrappers and foreign tables were created for:

You create a foreign server pointing to the source server, and then a foreign table that enables access to that remote server.

Some examples for that are in the description of the Postgres foreign data wrapper:


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.