Search Postgresql Archives

Re: Possibly odd question; diff results?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux