Postgres – Dump data as INSERT SQL Statements

I wanted to get data from a production database into my local machine that didn’t have the same users, schema, etc. I created a local table and then used the pg_dump to dump out data as insert statements – that helped me out. Here’s what I used to dump data as insert statements:

pg_dump -U user_name -h localhost -t table_name --data-only --column-inserts db_name > data_dump.sql
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