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!

Compare tables of two database users using MINUS operator

mradul goyalApr 2 2015 — edited Apr 2 2015

Hi,

I have this requirement to compare all tables of two different DB users and then create a spool file for the same using SQL script.

Here is a brief about the requirement

DB Version :

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

PL/SQL Release 11.2.0.3.0 - Production

CORE 11.2.0.3.0 Production

TNS for Linux: Version 11.2.0.3.0 - Production

NLSRTL Version 11.2.0.3.0 - Production

Suppose i have two DB user both have same SID suppose sid11g as

1. net1cm

2.net7cm

Now first i need to create a DB link between these two users

after creating DB link i need to prepare a SQL script which will compare all the tables of these two users and then output of that script will be written into a spool file

Here in my database these users have almost 360 tables which i need to compare.

So here for example

net1cm user having tables

1.  sub

2.  svc

3.  sub_parm

4.  svc_parm

5.  subntwk

6.  location

7.  sub_addr

8.  sub_svc

9.  sub_svc_parm

10.sub_svc_ntwk


And user net7cm also have these tables (Here in this example i am mentioning only 10 tables whereas my database has as much as 360 tables for these users.)

So the SQL for complaring will be like


select * from sub

minus

select * from sub@remote_net7cm


Now i am facing problem like as i have mention i have lots of tables to compare do i need to write SQL for all these tables or there could be a dynamic way so as the script will take tables name one by one.

please ask me if more information is required to rebuild the requirement.


Thanks

This post has been answered by John Stegeman on Apr 2 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2015
Added on Apr 2 2015
16 comments
3,954 views