0

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
  • 2
    pg_dump creates all constraints and indexes at the end, so the order of the inserts isn't really relevant. Oct 23 '21 at 7:37
  • oh cool, will try to do this hard cutover with this way (since bucardo has an error)
    – Kokizzu
    Oct 23 '21 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.