Re: Comparing tables in different db's
От | Oliver Elphick |
---|---|
Тема | Re: Comparing tables in different db's |
Дата | |
Msg-id | 200108101025.f7AAPMYx012487@linda.lfix.co.uk обсуждение исходный текст |
Ответ на | Comparing tables in different db's (Phillip F Jansen <pfj@ucs.co.za>) |
Список | pgsql-hackers |
Phillip F Jansen wrote: >I would like to know if there is a way to compare the data of tables in >different databases. Forexample I have table in db1 and exactly the >same table in db2. Is it possible to see if the contents of the two >tablesare exactly the same? >For example if the table(db1.customer) has a column surname and the >field has a value of "Testing"and in db2.customer the exact same row >has a value "Testong" is it possible to actually know that there is a >difference? I don't actually have to know what the actual differences >are , I must just know that there is a difference. You can't do it inside PostgreSQL. However, this shell script will do it: psql -d db1 -tc "SELECT surname FROM customer WHERE id = 'xxx'" >db1.out psql -d db2 -tc "SELECT surname FROM customer WHEREid = 'xxx'" >db2.out if ! diff db1.out db2.out >/dev/null then echo Databases differ fi rm db[12].out -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47 GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "If ye abide in me, and my words abide in you, ye shall ask what ye will,and it shall be done unto you." John 15:7
В списке pgsql-hackers по дате отправления: