Solved

Materialized Views w Refresh Fast on Commit

Posted on 2004-10-04
8
1,550 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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.  …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to recover a database from a user managed backup

734 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