Solved

Materialized Views w Refresh Fast on Commit

Posted on 2004-10-04
8
1,537 Views
Last Modified: 2008-01-16
Hi all,

I am using Oracle 9.2.0.5 and want to create a mat view with simple joins between three tables. When I try:

create materialized view test1
refresh fast on commit
as
SELECT a.col1, b.col1, c.col1
from table1 a, table2 b, table3 c
where a.columns = b.columns
and b.columns = c.columns

It says "ORA-12052: cannot fast refresh materialized view TEST1"

I have created mat view logs on the base tables and after some research I found that:

"Rowids of all the tables in the FROM list must appear in the SELECT list of the query. " - From the Oracle doco

so i tried:

create materialized view test1
refresh fast on commit
as
SELECT a.rowid, b.rowid, c.rowid, a.col1, b.col1, c.col1
from table1 a, table2 b, table3 c
where a.columns = b.columns
and b.columns = c.columns

but now it gives me "ORA-00904: "ROWID": invalid identifier"

How can I get this working???
0
Comment
Question by:MrNed
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 250 total points
ID: 12223710
If your statement were to work, and you submitted "SELECT rowid, col1 FROM test1" which column would it report for rowid? It'd have three to choose from. Same with Col1. You just need to give them aliases:

create materialized view test1
refresh fast on commit
as
SELECT a.rowid as rowidA, b.rowid as rowidB, c.rowid as rowidC, a.col1, b.col1, c.col1
from table1 a, table2 b, table3 c
where a.columns = b.columns
and b.columns = c.columns
0
 
LVL 6

Expert Comment

by:morphman
ID: 12224263
make sure your materialized view log has been created with rowid

create materialized view log on table1 with rowid(col1);
create materialized view log on table2 with rowid(col1);
create materialized view log on table3 with rowid(col1);
0
 
LVL 7

Author Comment

by:MrNed
ID: 12224384
Thanks jdlambert1 - it was staring at me in the face!

Morphman - yes i have.

To do with the same issue, can anyone tell me why i get the error "ORA-12053: this is not a valid nested materialized view" when trying to create another mat view of the one above?

create materialized view test2
refresh fast on commit
as
select col1, col2, col3, min(col4)
from test1
group by  col1, col2, col3

Even removing the min(col4) gives the same error.
0
 
LVL 6

Expert Comment

by:morphman
ID: 12224389
You cannot use MIN with fast refresh. Its one of the limitations. You cannot use MAX either.

Not sure why you get the error if you remove min(col4) though.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 11

Expert Comment

by:cjjclifford
ID: 12224474
removing min(col4) still leaves implicit aggregation, done by the "group by".
If you remove min(col4) and the "group by" then the second one should be ok, although not very useful (will contain the same as the "test1" Mview.
0
 
LVL 7

Author Comment

by:MrNed
ID: 12233470
i was able to create a mat view with a group by on a normal table - so its a limitation that it cant do that with mat views instead of a normal table?
0
 
LVL 11

Expert Comment

by:cjjclifford
ID: 12235443
Sorry, I was thinking the "group by" was intruducing an implicit aggregation function, which is not allowed for fast refresh views... when you tested with normal table did you use fast refresh? If so, you've got me stumpped why it works on table and not on mview...

Cheers,
C.
0
 
LVL 7

Author Comment

by:MrNed
ID: 12337266
Yes i used fast refresh for the normal table. I still havent found out a solution for this, but have used triggers to maintain a normal table instead.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now