1

Is it possible to dump then recreate with proper table analysis, so for example if table A depends on table B, then table B will be dumped first, then the table A

something like

CREATE TABLE B(...);

COPY ... TO B;

CREATE TABLE A(...);

COPY ... TO A;

ALTER TABLE A ADD FOREIGN KEY ... REFERENCES B(...);
CREATE INDEX ON A ....;

I'm trying to dump from one database to another database directly:

pg_dump -U user1 -h db1.rds.amazonaws.com db1 | 
pv | 
psql -U user2 -h localhost -p 15432 db2
2
  • 3
    pg_dump creates all constraints and indexes at the end, so the order of the inserts isn't really relevant.
    – user1822
    Oct 23, 2021 at 7:37
  • oh cool, will try to do this hard cutover with this way (since bucardo has an error)
    – Kokizzu
    Oct 23, 2021 at 9:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.