Suppose I have two tables, t1 and t2 which are identical in layout but which may contain different data.
What's the best way to diff these two tables?
Compare columns in two tables and list out column names which are different. for ex:- create table t1(c1 number(2), c2 varchar2(10)); create table t2(c1 number(2), c2 varchar2(10)); insert into t1 values(1,'a'); insert into t2 values(1,'b'); result should be column c2 is different.
Using joins to compare columns by priority among the table. For example, left join returns all values from the first table and null value for the not-matched records from the second table. Similarly, we can use right join, inner join, full join and self join as per our requirements.
Try this:
(select * from T1 minus select * from T2) -- all rows that are in T1 but not in T2 union all (select * from T2 minus select * from T1) -- all rows that are in T2 but not in T1 ;
No external tool. No performance issues with union all
.
You can try using set operations: MINUS
and INTERSECT
See here for more details:
O'Reilly - Mastering Oracle SQL - Chapter 7 - Set Operations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With