Check If Two Tables Are Identical

Whether you are migrating a table, rebuilding it, testing recovery or just need to compare two tables if they are identical this script will help you to achieve it

SELECT count(*)
FROM (
      (
       SELECT * FROM table_A 
        MINUS 
       SELECT * FROM table_B
      )
       UNION
      (
       SELECT * FROM table_B 
        MINUS 
       SELECT * FROM table_A
      )
    );

If the count is different from zero the tables are not identical!

There are some things you have to consider before you start the comparison! All dynamic a session individual values (such as sequences, sysdate or timestamp to name few) will result as non-identical.