1

Can any one tell me , How can i take database dump using pg_dump without getting specific table records.

1 Answer 1

1

If you want a table-wide filter, you can use either --exclude-table=table or --table=table to resp. exclude tables or include only the tables you want.

If you want to "filter out" some records, then you have no direct option to do it. My best advice is to:

  1. dump your full database
  2. restore it as another name (so you now have a copy of your original DB)
  3. DELETE the records you wish to get rid of
  4. dump the database

This is of course quite rudimentary, and there might be other solutions suitable to your needs. E.g. dump using plain text format then manually edit the dump to remove the rows.

Sign up to request clarification or add additional context in comments.

1 Comment

Another way is to create a new table with just the records you want and dump that. select * into holdingtable from actualtable where id in (1,2,5,6); then pg_dump -t holdingtable

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.