Re: A compare and/or sync. database structure?

Поиск
Список
Период
Сортировка
От Guillaume Lelarge
Тема Re: A compare and/or sync. database structure?
Дата
Msg-id 200908051049.53982.guillaume@lelarge.info
обсуждение исходный текст
Ответ на A compare and/or sync. database structure?  ("durumdara@gmail.com" <durumdara@gmail.com>)
Ответы Re: A compare and/or sync. database structure?
Список pgsql-general
Le mercredi 5 août 2009 à 10:13:44, durumdara@gmail.com a écrit :
> [...]
> So please help me with your experience: what is the best solution, what is
> the possible problem that make mistakes with this plan, and how to realize
> it easily?
>

You can try check_postgres.pl Perl script. The same_schema action seems to be
what you need.

Here is a little example:

guillaume@laptop:~$ createdb db1
guillaume@laptop:~$ psql -c "CREATE TABLE t1(id integer);" db1
CREATE TABLE
guillaume@laptop:~$ psql -c "CREATE TABLE t2(id integer, c text);" db1
CREATE TABLE
guillaume@laptop:~$ createdb db2
guillaume@laptop:~$ psql -c "CREATE TABLE t1(id integer);" db2
CREATE TABLE

So, db1 with two tables and db2 with one only.

guillaume@laptop:~$ LANG=C check_postgres.pl --action same_schema --dbname db1
--dbname2 db2
POSTGRES_SAME_SCHEMA CRITICAL: DB "db1 => db2" Databases were different. Items
not matched: 1 | time=0.01  Table in 1 but not 2: public.t2

It works. Now I add the missing table:

guillaume@laptop:~$ psql -c "CREATE TABLE t2(id integer, c text);" db2
CREATE TABLE
guillaume@laptop:~$ LANG=C check_postgres.pl --action same_schema --dbname db1
--dbname2 db2
POSTGRES_SAME_SCHEMA OK: DB "db1 => db2" Both databases have identical items |
time=0.01

Works too. Works great actually :)

It works also with the other objects of the database.

Regards.


--
Guillaume.
 http://www.postgresqlfr.org
 http://dalibo.com

В списке pgsql-general по дате отправления:

Предыдущее
От: "durumdara@gmail.com"
Дата:
Сообщение: A compare and/or sync. database structure?
Следующее
От: Bill Moran
Дата:
Сообщение: Re: Does derby have an embedded Mode like Derby ?