Re: dump-restore only one table - Mailing list pgsql-general

From Tom Lane
Subject Re: dump-restore only one table
Date
Msg-id 169.1178052523@sss.pgh.pa.us
Whole thread Raw
In response to Re: dump-restore only one table  (Alexander Kuprijanov <sanya-spb@list.ru>)
List pgsql-general
Alexander Kuprijanov <sanya-spb@list.ru> writes:
> % pg_dump -d test_a --table=b -F c -v -f b.backup

That syntax doesn't actually work in any reasonably modern version
of pg_dump ... what are you really typing?  (-d is not a switch for
specifying the database name.)

But at any rate, I still can't duplicate the behavior you show of
pg_restore not trying to restore the data.  What I get with this
test case (after fixing the command syntax) is

pg_restore: connecting to database for restore
pg_restore: restoring data for table "b"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1612; 0 67454 TABLE DATA b sanya
pg_restore: [archiver (db)] COPY failed: ERROR:  duplicate key violates unique constraint "b_pkey"
CONTEXT:  COPY b, line 1: "1    3"
WARNING: errors ignored on restore: 1

which is what I'd expect given that there's conflicting data
already in the destination table.  Are you looking for an option to
delete the destination's existing data?  There isn't one in the
--data-only mode, AFAIR, but you could instead use the -c option
to drop and recreate the table.

            regards, tom lane

pgsql-general by date:

Previous
From: "Ed L."
Date:
Subject: Re: HP/Pgsql/DBD::Pg issue
Next
From: "Ed L."
Date:
Subject: Re: HP/Pgsql/DBD::Pg issue