PostgreSQL - copy data from one table, database, server to another table, another database, server

What would be the best way to copy data from one table, one database, one server to a table into another database, another server in PostgreSQL?

+7
postgresql
source share
2 answers

pg_dump allows you to reset only selection tables:

pg_dump -Fc -f output.dump -t tablename databasename 

(dump 'tablename' from the database 'databasename' to the file 'output.dump' in binary user format pg_dumps)

You can restore this dump to another server using pg_restore :

 pg_restore -d databasename output.dump 

If the table itself already exists in your target database, you can import only rows by adding the --data-only flag.

+11
source share

I shared a shell for copying a table from one server to another PostgreSQL server. Please refer to this question on another stack. Copying a PostgreSQL database to another server

0
source share

All Articles