Copy a table from one database to another in Postgres

postgresql

Solution

Extract the table and pipe it directly to the target database:

pg_dump -t table_to_copy source_db | psql target_db

Note: If the other database already has the table set up, you should use the `-a` flag to import data only, else you may see weird errors like "Out of memory":

pg_dump -a -t table_to_copy source_db | psql target_db

Problem

I am trying to copy an entire table from one database to another in Postgres. Any suggestions?

Original source

Related problems