How to use PG_DUMP?

Started by Andre Lopesabout 16 years ago3 messagesgeneral
Jump to latest
#1Andre Lopes
lopes80andre@gmail.com

Hi,

I'am having trouble using PG_DUMP. The problem is the following, I have made
some minor changes to my database, I have added one table.

I have generated the CREATE statements using a modeling tool, and I have
created another database to test the changes. My problem is the order of the
INSERT statements generated by PG_DUMP [-a -d], causing errors because of
the order of the INSERTS.

I have tested PG_DUMP [-a] that creates the COPY statements, but no data is
added to the tables.

How can I solve this?

Best Regards,

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andre Lopes (#1)
Re: How to use PG_DUMP?

Andre Lopes <lopes80andre@gmail.com> writes:

I have generated the CREATE statements using a modeling tool, and I have
created another database to test the changes. My problem is the order of the
INSERT statements generated by PG_DUMP [-a -d], causing errors because of
the order of the INSERTS.

If you are talking about foreign key constraint failures, the best way
is to use a regular dump (not -a). pg_dump will order the data and
constraint creations properly then.

regards, tom lane

#3Andre Lopes
lopes80andre@gmail.com
In reply to: Tom Lane (#2)
Re: How to use PG_DUMP?

Hi,

I have tested with "pg_dump -u -p 5432 -d -f c:\test.sql mydatabase" but
the order of the INSERTS it is not the correct. What PG_DUMP does is to add
the CONSTRAINTS after doing the INSERTS. There is a way to have the correct
order of the INSERTS?

I have tested the COPY but does not insert nothing.

What can I do?

Best Regards,

On Sun, Jan 24, 2010 at 5:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Andre Lopes <lopes80andre@gmail.com> writes:

I have generated the CREATE statements using a modeling tool, and I have
created another database to test the changes. My problem is the order of

the

INSERT statements generated by PG_DUMP [-a -d], causing errors because of
the order of the INSERTS.

If you are talking about foreign key constraint failures, the best way
is to use a regular dump (not -a). pg_dump will order the data and
constraint creations properly then.

regards, tom lane