tags:

views:

29

answers:

1

I'm looking for a way to get all rows as insert statements from one specific table within a database using pg_dump in postgres.

eg I have table A and all rows in table a I need as INSERT STATEMENTS, it should also dump those staements to a file

Is this possible?

+1  A: 
pg_dump -D -t <table> <database>

Add -a before the -t if you only want the INSERTs, without the CREATE TABLE etc to set up the table in the first place.

psmears
The -d and -D options were removed from PostgreSQL 8.4 (see 8.4.0 release notes). You must now use the "long" names: pg_dump --column-inserts --data-only --table=<table> <database>
Matthew Wood