I have two databases on the same server and need to copy data from a table in the first db to a table in the second. A few caveats:
- Both tables already exist (ie: I must not drop the 'copy-to' table first. I need to just add the data to the existing table)
- The column names differ. So I need to specify exactly which columns to copy, and what their names are in the new table
After some digging I have only been able to find this:
pg_dump -t tablename dbname | psql otherdbname
But the above command doesn't take into account the two caveats I listed.