niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Sybase
How to verify two tables are IDENTICAL
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Thomas Gagne
*nix forums beginner


Joined: 15 Mar 2005
Posts: 35

PostPosted: Thu Jul 06, 2006 6:42 pm    Post subject: How to verify two tables are IDENTICAL Reply with quote

For various reasons, we need to BCP-out of one database and BCP-in to
another. If both are on the same server what is the surest way to
compare two tables to make sure they're identical? I want to know that
each has the same number of rows with the identical information in each row.

I was wondering if there's a way to calculate a table's HASH and compare
the two HASHes.
Back to top
bret@sybase.com
*nix forums addict


Joined: 24 May 2005
Posts: 66

PostPosted: Fri Jul 07, 2006 2:23 am    Post subject: Re: How to verify two tables are IDENTICAL Reply with quote

Thomas Gagne wrote:
Quote:
For various reasons, we need to BCP-out of one database and BCP-in to
another. If both are on the same server what is the surest way to
compare two tables to make sure they're identical? I want to know that
each has the same number of rows with the identical information in each row.

I was wondering if there's a way to calculate a table's HASH and compare
the two HASHes.

Assuming the table has a primary key (not one of those odd cases
that allows duplicate rows) I think something like

select count(*) from db1..a
go
select count(*) from db2..b
go
select count(*) from db1..a, db2..b where a.c1 = b.c1 and a.c2 = b.c2
and ... a.cn = b.cn
go

If all three counts are the same, the two tables contain identical
data.

If the tables are on different servers that can talk to each other over
a network, then a proxy table could be used.

I suppose you could write a HASH function in Java, but I think it would
be hard
to guarantee that two identical HASH values really meant the data was
identical
and not merely two different sets of data that happen to produce the
same HASH value.

-bret
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Sun Nov 23, 2008 12:05 pm | All times are GMT
navigation Forum index » Databases » Sybase
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Creating a relationship between 2 tables Andyza Oracle 2 Thu Jul 20, 2006 1:11 pm
No new posts Linking Tables from 2 databases Pratik Shukla PostgreSQL 2 Wed Jul 19, 2006 5:54 pm
No new posts Basic IP Tables issue spec networking 3 Wed Jul 19, 2006 3:57 pm
No new posts deleting tables using script manish shell 3 Wed Jul 19, 2006 5:47 am
No new posts Procedure Dependencies and Temporary Tables phil@querytool.com IBM DB2 1 Tue Jul 18, 2006 10:53 pm

Remortgages | Loan | Free Advertising | Cheap Loan | Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1282s ][ Queries: 16 (0.0574s) ][ GZIP on - Debug on ]