Oracle - difference or changes between two rows from two tables
NickName:rs. Ask DateTime:2009-10-20T05:23:30

Oracle - difference or changes between two rows from two tables

I have two tables both have same schema, one will have previous day records other will have current. I want to compare both and find only changes or only rows that have different value in atleast one column.

How is this possible in pl/sql, oracle? (I did code something similar using checksum in T-SQL but not sure how to do in pl/sql)

Copyright Notice:Content Author:「rs.」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/1591243/oracle-difference-or-changes-between-two-rows-from-two-tables

Answers
Doug Porter 2009-10-19T22:09:53

This SO answer provides a very efficient solution using Oracle to compare the results of 2 queries: Proving SQL query equivalency",


LBushkin 2009-10-19T21:36:49

You want an exclusive-difference query, which is is essentially an (A-B) U (B-A) query:\n\n(SELECT * FROM TODAY_TABLE\nMINUS\nSELECT * FROM YESTERDAY_TABLE)\nUNION ALL\n(SELECT * FROM YESTERDAY_TABLE\nMINUS\nSELECT * FROM TODAY_TABLE)\n\n\nThis query can also be easily improved to also show which records are inserts, deletes, and changes using an additional calculated column.",


More about “Oracle - difference or changes between two rows from two tables” related questions

Oracle - difference or changes between two rows from two tables

I have two tables both have same schema, one will have previous day records other will have current. I want to compare both and find only changes or only rows that have different value in atleast one

Show Detail

Find difference between two big tables in PostgreSQL

I have two similar tables in Postgres with just one 32-byte latin field (simple md5 hash). Both tables have ~30,000,000 rows. Tables have little difference (10-1000 rows are different) Is it possi...

Show Detail

finding the difference in data between two tables

So I have been trying to find the difference in data between two tables. In one of my tables (old data) I have roughly around 16,000 rows of data. In my new table I have around 18,000 rows of data....

Show Detail

Select difference between two tables

I want to list four columns, date, hourly count, daily count and difference between two counts. I have used union all for two tables, but I am getting 2rows as shown in the image: Select a.date, a...

Show Detail

Difference in number of rows in two tables

How can I take a difference in the counts of the number of rows in two different tables? SQL> select count(*) from dual44; COUNT(*) ---------- 3 SQL> select count(*) from dual;

Show Detail

Calculate difference between two non-adjacent rows

How can I calculate time difference between two rows in a table, based on a value in another field in the table. Table (simplified) look like; Unit Date Status 0001 17.11.2017 09:52

Show Detail

difference between data in two tables

I have two tables in a database in SQL server 2008, both tables have 20 column.At first the data was inserted in table A and later the same data was reentered in table B. Now I want to check what i...

Show Detail

In Oracle, is there a function that calculates the difference between two Dates?

In Oracle, is there a function that calculates the difference between two Dates? If not, is a way to display the difference between two dates in hours and minutes? Query: SELECT Round(max((EndDa...

Show Detail

Difference between two identical tables in mysql

I've two tables that are defined exactly the same but have different number of rows. There are five fields that are partial keys of the tables(which is the primary key for both the tables). I wante...

Show Detail

Major performance difference between two Oracle database instances

I am working with two instances of an Oracle database, call them one and two. two is running on better hardware (hard disk, memory, CPU) than one, and two is one minor version behind one in terms of

Show Detail