Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query optimisation?

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I need to run a query the contents of two identical tables on two DB schemas, whose ORACLE_SID are set to set1 and set2

questions-
1) If I set ORACLE_SID to set1 on UNIX command prompt and lauch SQL Plus, how could I refer to table1 in set2?

2) There are many fields in the table, and I need to run a query of format
(Syntax is incorrect)
Code:
select * from table1 where table1.pk=set2.table1.pk AND table1.field1<>set2.table1.field1 AND table1.field2<>set2.table1.field2 AND 
table1.field3<>set2.table1.field3 AND 
etc etc.

Could this query by optimized to speed things up a bit??
 
Few things,
1) multiple schemas can reside in a single oracle database (ORACLE_SID).
If that is the case, you may refer your tables e.g. as
select t1.col1,t2.col1
from s1.table1 t1, s2.table1 t2
where t1.key_col=t2.key_col;

2) if you schemas are in two different databases, then you need to create a database link in the database where you want to execute your query linking to the second database.After that statement should be something like this

select s1.col1,s2.col1
from s1.table1 t1, s2.table1@dblink t2
where t1.key_col=t2.key_col;

Lastly, for any suggestion on optimization you may post your final query.

Hope it helps


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top