Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle view pulling data from schemas in different instances?

Tags:

oracle

view

How can you create an Oracle view that reads data from two schemas in two different instances?

We know how to do this with two schemas in the same instance:

CREATE VIEW MYVIEW AS 
SELECT X,Y,Z FROM A.MYTABLE
UNION 
SELECT X,Y,Z FROM B.MYTABLE

But what if schemas A and B are in different Oracle instances?

like image 344
Marcus Leon Avatar asked May 05 '11 09:05

Marcus Leon


1 Answers

You could create a database link: http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/ds_concepts002.htm#ADMIN12092 and then do

CREATE VIEW MYVIEW AS  
SELECT X,Y,Z FROM A.MYTABLE 
UNION  
SELECT X,Y,Z FROM B.MYTABLE@<LinkName>
like image 92
StevieG Avatar answered Nov 29 '22 09:11

StevieG