On 2/8/07, Madison Kelly <linux@alteeve.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