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
    Commented Oct 23, 2021 at 7:37
  • oh cool, will try to do this hard cutover with this way (since bucardo has an error)
    – Kokizzu
    Commented Oct 23, 2021 at 9:28

0

Your Answer

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

Browse other questions tagged or ask your own question.