will pg_restore overwrite the existing tables?

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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)