Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query or stored proc to compare data between two tables

IQOct 3 2016 — edited Oct 3 2016

Hi all,

  I am using a query to find differences in data between two similar tables with similar structures. The Query is something as shown below.

My problem is this works with smaller data sets but in my case since I have big tables, this gives a memory error. Is there any other workaround I can try, please advise.


Thanks

IQ

select * from (
    select id, name,
    sum(case when src=1 then 1 else 0 end) cnt1,
    sum(case when src=2 then 1 else 0 end) cnt2
from
    (
    select id, name, 1 src from A
    union all
    select id, name, 2 src from B
    )
group by id, name
)
where cnt1 <> cnt2;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2016
Added on Oct 3 2016
5 comments
374 views