Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Mladen Gogala Newsgroups: comp.databases.postgresql Subject: Re: postgres 9.0 - NOT IN over 2 databases Date: Sun, 28 Aug 2011 16:08:34 +0000 (UTC) Organization: solani.org Lines: 31 Message-ID: References: <4e596484$0$315$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: solani.org 1314547714 32222 eJwNxMEBgDAIA8CVWiTBjhOi7D+C3uNwcdOVBBODKUdXtDS2B4VkapE4d8p89noTcu+/kM8HLNERsQ== (28 Aug 2011 16:08:34 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 28 Aug 2011 16:08:34 +0000 (UTC) User-Agent: Pan/0.133 (House of Butterflies) X-User-ID: eJwNyskBwDAIA7CVMIdpxikB9h+h1VthBG86gx4bK1KhY64qdzFwS2ED2ebzH7TVAeCHiXreD/tQD8Q= Cancel-Lock: sha1:GPFFGYc/NKOH8NLtvp6YUWac6jU= X-NNTP-Posting-Host: eJwNyUcBA0EMBDBKmXWH48ofwkVfCSm0jVWU5eRWgydgiyUNlM5Lmt5HI/ny7vVv2NHlLF4NaUv3NJR3aq1H8fxLuAyDD+c2Glg= Xref: x330-a1.tempe.blueboxinc.net comp.databases.postgresql:217 On Sat, 27 Aug 2011 23:41:31 +0200, Bjarne Jensen wrote: > I get a "new" database every 4 weeks. They all have the same schema. > > I need to find out what changes were done to certain tables from one > issue to the next. > > Presently I COPY a table from OLD_db to file and then import it in the > NEW_db where I can compare the tables - like this: > > SELECT a,i FROM db_OLD_t WHERE i NOT IN (SELECT i FROM db_NEW_t); > > Now, is there some way I can create a (as in 'one') query that can span > 2 databases? > > > /Bjarne The dblink extension will help you with that. Essentially, you create another connection and retrieve the query results. Here is the documentation: http://www.postgresql.org/docs/current/static/dblink.html If you don't want that, there is always replication like Slony, which is simple to set up and works very reliably, at least in my experience. There is nothing like "select * from emp@dblink" in Postgres. -- http://mgogala.byethost5.com