Re: Comparing two tables of different database
От | Nicholas I |
---|---|
Тема | Re: Comparing two tables of different database |
Дата | |
Msg-id | e13d0d10904300312j5ec7baa1l3ae91724f6f5dbf8@mail.gmail.com обсуждение исходный текст |
Ответ на | Comparing two tables of different database (Nicholas I <nicholas.domnic.i@gmail.com>) |
Ответы |
Re: Comparing two tables of different database
Re: Comparing two tables of different database |
Список | pgsql-sql |
Hi All, <br /><br /> For example, <br /><br /> There are two database. database1 and database 2;<br /> <br /> database1 has a table called pr_1 with the columns, id,name and time.<br /> database2 has a table called sr_1 withthe_columns id,name and time.<br /> <br /> i would like to find out the differences that is, find the names thatare not in sr_1 but in pr_1.<br /> we can achieve this by the query, <br /> <br /> select name from sr_1where name not in (select name from pr_1);<br /> the above query will work in case of two tables in the same database.<br/><br /><br /> But the problem is, these two tables are in different database. i did not understand aboutthe dblink.<br /><br /> is there any exaples on dblink. can we do it without using dblink.<br /><br />-Nicholas I<br/> <br /> <br /><br /><div class="gmail_quote">On Thu, Apr 30, 2009 at 9:07 AM, Joshua Tolley <span dir="ltr"><<ahref="mailto:eggyknap@gmail.com">eggyknap@gmail.com</a>></span> wrote:<br /><blockquote class="gmail_quote"style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><divclass="im">On Thu, Apr 30, 2009 at 08:20:02AM +1000, Adam Ruth wrote:<br /> > The simple answer is to pg_dumpboth tables and compare the output with<br /> > diff.<br /> > Other than that, I think you'll need a customprogram.<br /><br /></div>For all but the strictest definition of "identical", that won't work.<br /> Tables may easilycontain the same information, in different on-disk<br /> order, and pg_dump will most likely give the data to you inan order<br /> similar to its ordering on disk.<br /><br /> Something like a COPY (<query>) TO <file>, where<query> includes an<br /> ORDER BY clause, might give you a suitable result from both tables, on<br /> which youcould then take a checksum.<br /><br /> - Josh / eggyknap<br /><br />-----BEGIN PGP SIGNATURE-----<br /> Version: GnuPGv1.4.9 (GNU/Linux)<br /><br /> iEYEARECAAYFAkn5HQoACgkQRiRfCGf1UMPcagCfQDRa2bXPRjgSuVsrFYTnGTTC<br /> rhoAnAlGwp0vSKd2uspyFvxCTfugG6Yh<br/> =LO6r<br /> -----END PGP SIGNATURE-----<br /><br /></blockquote></div><br />
В списке pgsql-sql по дате отправления: