How to find if one table is replica of other table in SQL
Asked
Active
Viewed 418 times
-2
-
2Which one? SQL Server? MySQL? Oracle? – Praveen Kumar Purushothaman Aug 12 '15 at 14:42
-
2What RDBMS are you using? – fez Aug 12 '15 at 14:42
-
1possible duplicate of [How to verify if two tables have exactly the same data?](http://stackoverflow.com/questions/2129717/how-to-verify-if-two-tables-have-exactly-the-same-data) – Praveen Kumar Purushothaman Aug 12 '15 at 14:42
2 Answers
1
In SQL Server, you can compare the results of:
SELECT checksum_agg(checksum(*))
FROM Table1;
SELECT checksum_agg(checksum(*))
FROM Table2;
You could create a join with these as sub-queries if you want, too.
You may wish to use binary_checksum()
instead of checksum()
. The doc says that checksum()
will treat strings that are equal as equal according to the collation (i.e., 'hello'
and 'HELLO'
if the collation is case-insensitive), while binary_checksum()
compares the raw binary values of characters.

Bacon Bits
- 30,782
- 5
- 59
- 66
0
This works for MySQL:
CHECKSUM TABLE table_1, table_2;

Praveen Kumar Purushothaman
- 164,888
- 24
- 203
- 252