Wednesday, March 6, 2013

Dump Certain table from postgresql Server-A to postgresql Server-B

Problem:

Need to Dump Table user_data_login and restore it at Server-B from Server-A
DataBase Name: users_DB
User: postgres

At Server A

as postgres user

pg_dump --table=user_data_login users_DB -f /tmp/users_data.sql

At Server B

assuming that the users_DB.sql has been copied at /tmp/users_data.sql

execute the command below as postgres user

psql -d users_DB -f /tmp/users_data.sql

that's it.