Migrate tables from one PostgreSQL database to another using the INFORMATION_SCHEMA

Photo by Viviana Couto Sayalero on Unsplash

The request

Recently a client asked us to create a database migration process between two PostgreSQL databases. This would have been a very trivial process, but for the following restriction…

We didn’t have access to the source database and the client could not provide us with the schema due to their strict data management policy.

So in essence we had to create a script that would migrate a list of tables, schema and data, from one database to another without having to specify the exact schema for each table.

Read more in Medium · 2 min read


  • PostgreSQL
  • PSQL
  • Python
  • SQL

Thanasis Politis

CTO and Systems Architect