On Thu, 2011-09-01 at 13:09 -0400, Jerry LeVan wrote:
> As time goes by the tables on the various computers get out of
> sync.
> 
> Is there an elegant way I can get all of the differences (uniquely)
> merged into a single table?

You can try a query involving NOT EXISTS, combined with dblink: 

http://www.postgresql.org/docs/current/static/dblink.html

Effectively the query would be something like: 

INSERT INTO registrations
 SELECT * FROM 
  -- fetch remote version of table
  dblink(..., "SELECT * FROM registrations") AS remote_reg(...)
 WHERE NOT EXISTS
  (SELECT 1 FROM registrations local_reg
   WHERE local_reg.id = remote_reg.id);

(disclaimer: I didn't test this query out, it's just for illustrating
the idea).

Regards,
        Jeff Davis


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to