pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedcompare two databases
5+ messages / 5 participants
[nested] [flat]
* compare two databases
@ 2003-11-16 13:14 Ashok Chauhan <ashok@kalculate.com>
0 siblings, 1 reply; 5+ messages in thread
From: Ashok Chauhan @ 2003-11-16 13:14 UTC (permalink / raw)
To: pgsql-admin
there is any utility or command for compare two databases,
tables structure (schema).
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: compare two databases
@ 2003-11-16 14:09 Bruno LEVEQUE <bruno.leveque@net6d.com>
parent: Ashok Chauhan <ashok@kalculate.com>
0 siblings, 1 reply; 5+ messages in thread
From: Bruno LEVEQUE @ 2003-11-16 14:09 UTC (permalink / raw)
To: Ashok Chauhan <ashok@kalculate.com>; +Cc: pgsql-admin
Maybe you can use :
pg_dump -s -t Thetable firstdatabasename > first
pg_dump -s -t Thetable seconddatabasename > second
diff first second
Bruno
Ashok Chauhan wrote:
>there is any utility or command for compare two databases,
>tables structure (schema).
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
>
--
Bruno LEVEQUE
System Engineer
SARL NET6D
bruno.leveque@net6d.com
http://www.net6d.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: compare two databases
@ 2003-11-16 14:46 Yuji Shinozaki <ys2n@virginia.edu>
parent: Bruno LEVEQUE <bruno.leveque@net6d.com>
0 siblings, 1 reply; 5+ messages in thread
From: Yuji Shinozaki @ 2003-11-16 14:46 UTC (permalink / raw)
To: Bruno LEVEQUE <bruno.leveque@net6d.com>; +Cc: Ashok Chauhan <ashok@kalculate.com>; pgsql-admin
Here's a question about that: Do dumps always occur
in a predictable row order?
If it is not the case, then you might need to sort each
table dump before the diff.
yuji
----
On Sun, 16 Nov 2003, Bruno LEVEQUE wrote:
> Maybe you can use :
>
> pg_dump -s -t Thetable firstdatabasename > first
> pg_dump -s -t Thetable seconddatabasename > second
>
> diff first second
>
>
>
> Bruno
>
>
> Ashok Chauhan wrote:
>
> >there is any utility or command for compare two databases,
> >tables structure (schema).
> >
> >
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> >
> >
> >
>
> --
> Bruno LEVEQUE
> System Engineer
> SARL NET6D
> bruno.leveque@net6d.com
> http://www.net6d.com
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
>
Yuji Shinozaki Computer Systems Senior Engineer
ys2n@virginia.edu Advanced Technologies Group
(434)924-7171 Information Technology & Communication
http://www.people.virginia.edu/~ys2n University of Virginia
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: compare two databases
@ 2003-11-17 16:51 Andrew Sullivan <andrew@libertyrms.info>
parent: Yuji Shinozaki <ys2n@virginia.edu>
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Sullivan @ 2003-11-17 16:51 UTC (permalink / raw)
To: pgsql-admin
On Sun, Nov 16, 2003 at 09:46:08AM -0500, Yuji Shinozaki wrote:
>
> Here's a question about that: Do dumps always occur
> in a predictable row order?
No, at least not between systems. I'm pretty sure that the same
system, if left unchanged between them, wil dump the tables in the
same order. They key to all this is understanding the implications
of lazy vacuum: tuples do not always stay in the same place on the
disk.
> If it is not the case, then you might need to sort each
> table dump before the diff.
Yes.
--
----
Andrew Sullivan 204-4141 Yonge Street
Afilias Canada Toronto, Ontario Canada
<andrew@libertyrms.info> M2P 2A8
+1 416 646 3304 x110
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: compare two databases
@ 2003-11-17 17:51 Reece Hart <reece@in-machina.com>
parent: Andrew Sullivan <andrew@libertyrms.info>
0 siblings, 0 replies; 5+ messages in thread
From: Reece Hart @ 2003-11-17 17:51 UTC (permalink / raw)
To: pgsql-admin
You might consider comparing the schemas with pg_dump -s and diff (as
was already suggested), then comparing the data with a (e.g.) perl DBI
script connected to two databases simultaneously.
If the two databases are truly descended from the same design (e.g.,
restored from the same dump), then I'd expect the dump order to be the
same and the diff probably won't be corrupted with false differences.
I'd strip lines matching /^--/ to facilitate the diff.
A simple-minded implementation (I excel here) of the perl-DBI part
doesn't require table-specific code. I'd do it like this: 1) connect to
both databases; 2) for each (common) table, create a statement which
selects rows in some canonical order (e.g., sorted by primary key or
some non-degenerate multi-column tuple), and then fetch into a hash
one-by-one (cursors would be better, but IIRC the DBI code doesn't
support them). Because you're fetching into a hash, you can write a
single routine to compare all elements of the common hash keys (you'll
already know of differences between keys/columns themselves from the
schema diff). This is not the speed-optimal solution, but it shouldn't
be too bad in total time and you'd probably spend even more time
implementing the optimal solution.
Obviously, this will miss certain diabolical changes like column or
table renames, but it should suffice for most mutations of two instances
from a common schema and content.
-Reece
--
Reece Hart, http://www.in-machina.com/~reece/, GPG:0x25EC91A0
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2003-11-17 17:51 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-11-16 13:14 compare two databases Ashok Chauhan <ashok@kalculate.com>
2003-11-16 14:09 ` Bruno LEVEQUE <bruno.leveque@net6d.com>
2003-11-16 14:46 ` Yuji Shinozaki <ys2n@virginia.edu>
2003-11-17 16:51 ` Andrew Sullivan <andrew@libertyrms.info>
2003-11-17 17:51 ` Reece Hart <reece@in-machina.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox