Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Materialized Views w Refresh Fast on Commit

Posted on 2004-10-04
8
Medium Priority
?
1,556 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 1000 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

719 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