Search code examples
postgresqlpostgres-fdw

Import and merge rails database tables


I have 3 separate ruby on rails applications running PostgreSQL databases, all with the same tables (and columns) but different values.

For example :

app 1 TABLE

name surname postcode
----------
tom  smith   so211ux

app 2 TABLE

name  surname postcode
----------
mark  smith   so2ddx

app 3 TABLE

name   surname   postcode
----------
james  roberts   F2D1ux

I am looking to export/dump/download from two of the databases and import into one consolidated database/app.

If someone could point me in the right direction/reading for this type of query I would be most grateful.


Solution

  • Please use the foreign data wrappers (fdw), where you can access the data from external postgresql servers. Please read more here - https://www.postgresql.org/docs/9.3/static/postgres-fdw.html