If you use the --clean
option of pg_restore
, the old tables will be dropped before the new ones are created.
If you do not use the --clean
option, you will get an error message that the table already exists, but pg_restore
will continue processing unless you use the --exit-on-error
option.
If your goal is to “merge” the existing data in the database and the data in the dump, you may be able to do that if you
-
create the dump with the options
--inserts --on-conflict-do-nothing
options -
ignore the errors you get from the
CREATE TABLE
statements -
have a primary key or unique constraint on all tables (that is necessary for
INSERT ... ON CONFLICT TO NOTHING
to work)