Postgres – pg_dump for specific tables

Use the following to get specific table dumps from a database (To be executed from shell and not from SQL prompt).

pg_dump [--schema-only] -t tableName DbName -U userName -h localhost -W > tmp.sql

-W signifies prompt for password.
–schema-only is optional. Use if only table definition is required.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s