Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Compare the data between two tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-27-02, 03:53
datasree datasree is offline
Junior Member
 
Join Date: Nov 2001
Location: hyderabad
Posts: 1
Compare the data between two tables

Hi all,

Can any one have the code to compare two tables.. data . and report the data in which columns it is changed...

My case is :
Tab1 has columns 200 and Tab2 has 200 columns.
Every day Tab1 is refreshed and Tab2 will contain the last data of Tab1.. in this case i need to compare the changed data in Tab1 comparing with the Tab2..

Any suggestions are most welcome...

Thanks
-Sreedhar
Reply With Quote
  #2 (permalink)  
Old 06-27-02, 04:02
Ruudboy Ruudboy is offline
Registered User
 
Join Date: Apr 2001
Location: Netherlands
Posts: 170
select * from table1
minus
select * from table2

will return all rows that are in table1 but not in table2.

(So all rows that have a changed value in table 1 will show up).
__________________
Ruud Schilders
-----------------
Oracle DBA
e-mail : ruudboy@gmail.com
URL : www.ruudschilders.com
ICQ : 397543
MSN: ruudboy@hotmail.com
For Oracle DBA's only:
http://www.oracledbaforum.com
Reply With Quote
  #3 (permalink)  
Old 06-29-02, 22:47
Brice Brice is offline
Registered User
 
Join Date: Jun 2002
Location: Indianapolis
Posts: 21
Depending on how many rows are in these tables, and if you have the liberty to do so, you might also consider implementing a timestamp column on both tables and an update trigger on tab1 to update the timestamp when any changes to the table (tab1) are made. If you also create an index on the primary key and this timestamp on both tables, the query may be more efficient. The drawback to this though, is that you will retrieve rows that have been changed, and then changed back to their original value. The timestamps will be off but the data may match. This does, however, have the advantage of showing which rows were active.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On