Re: Possibly odd question; diff results?

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Madison Kelly" <linux(at)alteeve(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Possibly odd question; diff results?
Date: 2007-02-09 13:53:35
Message-ID: b42b73150702090553i7d83d41m3a0c329fa9ca5dbd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/8/07, Madison Kelly <linux(at)alteeve(dot)com> wrote:
> Hi all,
>
> I've got a 'history' schema that records changes in the public schema
> tables over time. I use a trigger and function to do this. What I would
> like to do though, and this may not even be possible, is say something
> like (pseudo-code) "SELECT DIFF foo_name FROM history.foo WHERE
> foo_id=X;" and have a *nix 'diff' style results shown (sort of like
> looking at diffs in CVS/SVN).

you can start by using the 'except' boolean query operator;

select * from foo except * from bar; This will give you rows in foo
that are not exactly in bar (matching every field). If you want it in
both directions you can:

(select * from foo except select * from bar)
union
(select * from bar except select * from foo);

you can then take the results of these queries and mark up the text
however you want. Just a heads up: the boolean sql operators are
famous for generating sequential scans.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2007-02-09 14:47:11 Re: trigger for pg_authid
Previous Message Bruce McAlister 2007-02-09 13:31:16 Re: Automating databse creation