I know this is a weird request, but for some hacky reasons I can't avoid, I'd like to be able to consistently sync a few tables from one database to another. I know I could write out the functionality myself in a script, but I figure pg_dump and pg_restore will apply a lot of optimizations to the process that I'm not aware of myself.
What I'm wondering is if there's a way to have pg_restore overwrite the existing tables. Basically, in pseudo-code something like:
-- pseudo code
begin;
drop table to_restore;
drop table to_restore2;
drop table to_restore3;
-- etc
restore table to_restore;
restore table to_restore2;
restore table to_restore3;
-- etc
commit;
I'm also open to alternatives ways of doing this if this isn't so great.
COPYfrom to (or fdw, or dblink), or do not in transactionpg_restore, and no other extra SQL. What I'm wondering is if I can do with without the need to write my own code other than just callingpg_restore.pg_restore- loosing transaction is inavoidable