Copy a table from one database to another in Postgres

前端 未结 19 1176
慢半拍i
慢半拍i 2020-11-28 00:21

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

相关标签:
19条回答
  • 2020-11-28 01:12

    You can also use the backup functionality in pgAdmin II. Just follow these steps:

    • In pgAdmin, right click the table you want to move, select "Backup"
    • Pick the directory for the output file and set Format to "plain"
    • Click the "Dump Options #1" tab, check "Only data" or "only Schema" (depending on what you are doing)
    • Under the Queries section, click "Use Column Inserts" and "User Insert Commands".
    • Click the "Backup" button. This outputs to a .backup file
    • Open this new file using notepad. You will see the insert scripts needed for the table/data. Copy and paste these into the new database sql page in pgAdmin. Run as pgScript - Query->Execute as pgScript F6

    Works well and can do multiple tables at a time.

    0 讨论(0)
提交回复
热议问题