pg_dump -> import traject using "upsert" paradigm?
0
votes
1
answer
384
views
Well say I have two physically separate database and I wish to replace database B with data from A. Except that I wish to keep the data in B which does not exist in A?
So basically I'd go over each entry in A and use an insert-or-replace like:
INSERT INTO table_name (name, value)
VALUES ('hello', 'world')
ON CONFLICT (name) do nothing;
IE the following databases would be merged into the third:
A)
name | value
A | 1
B | 2
B)
name | value
B | 10
C | 20
MERGED)
name | value
A | 1
B | 2
C | 20
If I use the
-c
option from pg_dump
it would just throw away the "c" value in the merged table.
Asked by paul23
(483 rep)
Mar 16, 2021, 02:56 PM
Last activity: Apr 24, 2025, 05:03 AM
Last activity: Apr 24, 2025, 05:03 AM