Wednesday, April 6, 2011

How to Comapare two Tables Data Difference

Comparing two table is a common task in day to day life of DBA . The Table which has to be compare may on same database or on different database . If the tables are in different database then we can use the database link to compare the two table . Let's have a look on the below tables . 

SQL> select *   from  (
( select * from dept1
  minus                                    //  all rows that are in T1 but not in T2
  select * from dept2 )
union all
( select * from dept2 
  minus                                  // all rows that are in T2 but not in T1
  select * from dept1 )
)




Enjoy    :-) 




No comments: