creating a view of tables of a different database - oracle

Is it possible to create a view in a database A of tables of another database B? If possible, can somebody please help me, I'm totally clueless.

Of course, just use a database link. So, your view would be:
create or replace view my_view as
select some_columns
from my_table#the_other_database
Beware though it's not always that efficient and you may have some problems with queries doing things you don't expect. If there's any volume to the data you're trying to select it might be worth using a materialized view instead to take data cross server. Then you can select data from the server you're on currently, which'll probably be a lot quicker.

Related

Is there any advantages related to Performance in Oracle View

I'm learning about Oracle Views and I got the concept of views but little confused about performance.
I was watching video and there I listen that oracle view can increase the performance. Suppose I have created view like below.
CREATE VIEW SALES_MAN
AS
SELECT * FROM EMP WHERE JOB='SALESMAN';
Ok now I have executed query to get SALES_MAN detail.
SELECT * FROM SALES_MAN
Ok now confusion start.
I listened in video that once the above query SELECT * FROM SALES_MAN will be executed the DATA/RECORD will be placed into cache memory after hitting the oracle DB. and if I will execute same query( IN Current Session/Login ) Oracle Engine will not hit to Database and will give you record from CACHED-MEMORY is it right?
But I have read on many websites that View add nothing to SQL performance more
Another Reference that says view not help in performance. Here
So Views increase performance too or not?
A view is just a kind of virtual table defined by a query. It has no proper data and performance will depend on the underlying table(s) and the query definition.
But you also have Materialized View wich stores the results from the view query definition. Data is synchronized automatically, and you can add indexes to the view. In this case, you can achieve better performances. The cost to pay is
more space (the view contains data dupplicated),
no access to the up to date data from the underlying tables
You (and perhaps the creator of the un-cited video) are confusing two different concepts. The reason the data that was in the cache was used on the second execution was NOT because it was the second execution of the view. As long as data remains in the cache, it is available for ANY query that needs it. The very fact that the first execution of the view had to get the data from disk should be a strong clue. And what if your second use of the view wasn't until hours or days later when the data was no longer in the cache? The answer remains. A view does NOT improve performance.

which is better to use a view or a materialised view?

So I have a process to design where there are few base tables on which I have to create a view and from that view I will extract and derive data and insert into an another table.
we would use this last table for extracting reports
This process will run daily, since the data on the base tables have updates have everyday.
he whole purpose of this process is to make things "faster" for reporting,
So my concern here is with using the view. I am wondering if a materialized view would be better to use here in terms of performance instead the view or view itself would be the better.
Has anyone had to deal with such situation and found an approach that performs well and works efficiently??
Any leads on this would be highly appreciated

Synchronize two Oracle databases

I have two oracle databases. Database A and Database B. Database B should be in sync with Database A. Data within DB- B wont be altered, it is only for view purpose. All the data change in DB- A should reflect in DB- B. After googling, I found db link and Materialized view
could help but I am not clear how to use them. Please give any idea.
I think you need to read the following:
http://docs.oracle.com/cd/B19306_01/backup.102/b14191/rcmdupdb.htm
http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_overview.htm#SUTIL100
A materialized view can be used for replication purposes but what you are referring to is duplication not replication.
If you all have a DBA in your org most definitely hand this task over to them. These are the kind of problems they eat for breakfast.
Best of luck.

How to create a hierarchical query as a materilized view with refresh on commit in oracle

Could anyone please tell me if there is a possibility to create a hierarchical query in oracle 10g as a materialized view with REFRESH ON COMMIT?
I tried using CONNECT_BY but this doesn't work with REFRESH ON COMMIT.
Are there any other possibilities to get the view automatically refreshed when the underlying data changes?
Or may be there is an alternative to CONNECT_BY which works with REFRESH ON COMMIT?
Thanks in advance for any hints or help.
I really doubt that you'll be able to get this functionality. I think that the best you can hope for is to be able to define a materialized view that optimises the hierarchical query, for example by basing the MV on an underlying table that is actually index-organised or hash clustered on the parent_id column.

Oracle's materialized view: How to determine whether original tables were changed?

I've created a MV, on many tables. I don't want to auto-refresh it. I just want to know whether original tables were changed or not. What is the best way to do that?
If you created fast refresh MVs, you also created Materialied View logs on base tables.
You can Issue an select count(*) from corresponding MV log(is a table that contains the table name and an M_$ or something like).
But If you want just to know if a refresh is needed, you can safely shoot a fast refresh. It would be at light speed if there are no rows to refresh.

Resources