Materialized View and Refresh Fast
Hi,
Below is a sample query for generating a MV. Since I am new to Oracle,
Experts please help me.
create materialized view user1.mv_empdept refresh fast
as select * from user1.employee e
where exists(select * from user2.department d where d.deptId=e.deptid);
Is it possible to have a MV with objects from different schema of the same
database for Refresh Fast?
I ran into "insufficient privileges" error eventhough both user1 and user2 have sysdba privileges.
Thanks,
Jagan
Hi Ajiaz,
User user1 has select privileges on Department table.
if we omit "refresh fast" in the query, I am able to create the MV
create materialized view user1.mv_empdept refresh fast
as select * from user1.employee e
where exists(select * from user2.department d where d.deptId=e.deptid);
Regards,
Jagan Kumar K
Similar Messages
-
Issue with materialized view and fast refresh between Oracle 10g and 11g
Hi all,
I've hit a problem when trying to create a fast-refreshable materialized view.
I've got two databases, one 10.2.0.10, another 11.2.0.1.0, running on 32-bit Windows. Both are enterprise edition, and I'm trying to pull data from the 10g one into the 11g one. I can happily query across the database link from 11g to 10g, and can use complete refresh with no problem except the time it takes.
On the 10g side, I've got tables with primary keys and m.v. logs created, the logs being of this form ...
CREATE MATERIALIZED VIEW LOG ON table WITH PRIMARY KEY INCLUDING NEW VALUES
On the 11g side, when I try to create an m.v. against that ...
CREATE MATERIALIZED VIEW mv_table REFRESH FAST WITH PRIMARY KEY AS SELECT col1, col2 FROM table@dblink;
... I get an ORA-12028 error (materialized view type is not supported by master site).
After running the EXPLAIN_MVIEW procedure it shows this;
REFRESH_FAST_AFTER_INSERT not supported for this type mv by Oracle version at master site
A colleague has managed to build a fast-refresh m.v. from the same source database, but pulling to a different one than I'm using; his target is also 10g, like the (common) source, so I've no idea why I'm getting the 'not supported' message whilst he isn't.
I've been able, on previous projects, to do exactly what I'm trying to achieve but on those someone with more knowledge than me has configured the database!
I'm now stumped. I'm also no DBA but despite that it's been left to me to install the new 11g database on the 32-bit Windows server from scratch, so there are probably a couple of things I'm missing. It's probably something really obvious but I don't really know where to look now.
If anyone can give me any pointers at all, I'd be really grateful. This question is also duplicated in the Replication forum but hasn't had any replies as yet, so I'm reproducing it here in hope!
Thanks in advance,
SteveHi Steve,
You should have a look at metalink, Doc ID 1059547.1
If that does not help, there may be something else in Mater note ID 1353040.1
Best regards
Peter -
Creation of Materialized view and Materialized view log.
I wanted to create materialized view with 'REFRESH FAST ON COMMIT' option.
1) Table1 --it is partitioned range + list -- Added primary key
2) view1 -- having primary keys on view's base table
Steps:
1) create materialized view log on Table1 ; -- default primary key
2) create materialized view log on view1. --- It is giving below error.
ORA-00942: table or view does not exist
i wanted to create Materialized view like below
create materialized view
REFRESH fast ON commit
as
select ...
... from table1
where c1 in (select c1 from view1 where ... );
Question:
1) As i am getting above error while creating MV log on view. Can we create MV log on view or we have to create MV log on view base table?
2) To create MV with ''REFRESH FAST ON COMMIT' option , do we need to have primary key on master tables?
Any pointers on this will really helpful.
Thanks
PrasadAlso created MV LOG on 3 tables and tried with joins ..
create materialized view
REFRESH fast ON commit
as
select ...
... from table1 , tab2 t2,tab3 t3
where ....
and ...
Get same error ORA-12052: cannot fast refresh materialized view AVSYS.EVENT_LOG_MV
2052. 00000 - "cannot fast refresh materialized view %s.%s"
*Cause: Either ROWIDs of certain tables were missing in the definition or
the inner table of an outer join did not have UNIQUE constraints on
join columns.
*Action: Specify the FORCE or COMPLETE option. If this error is got
during creation, the materialized view definition may have be
changed. Refer to the documentation on materialized views. -
Query on Materialized view and materialized view log
I am creating a materialized view something like this.but getting following error:
ERROR at line 1:
ORA-12032: cannot use rowid column from materialized view log on "SCOTT"."EMP"
SQL> create snapshot log on scott.emp;
Materialized view log created.
SQL> create materialized view scott_emp refresh fast on demand as select deptno,sum(sal) sum_sal from scott.emp group by deptno;
ERROR at line 1:
ORA-12032: cannot use rowid column from materialized view log on "SCOTT"."EMP"
Note when i have my query in materialized view as "select * from emp;" in place of
"select deptno,sum(sal) sum_sal from scott.emp group by deptno;" This code works fine.
How do i have a materialized with with a group by clause.
Thanks in AdvanceGot the answer myself.
I wasnt adding all the required columns.
CREATE MATERIALIZED VIEW LOG ON scott.emp
WITH SEQUENCE, ROWID (<all the required columns>)
INCLUDING NEW VALUES;
Anyways,
Thanks guys... -
Materialized View and Database startup
I have materialized view created using following query
CREATE MATERIALIZED VIEW dept_mv_dltb
REFRESH FAST START WITH SYSDATE
NEXT SYSDATE + 1/1440
WITH PRIMARY KEY
AS SELECT * FROM department@phinixdept
I have log created on department table.
Whenever my database gets restarted, my mv doesnt get refreshed.
Please suggest a solution.It doesnt refresh ever again.
I am using Oracle 9.2.0.5
It does work after creation. But fails only when my database gets restarted.
Followings are the trace file contents
ORA-12012: error on auto execute of job 50
ORA-12560: TNS:protocol adapter error
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 803
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 860
ORA-06512: at "SYS.DBMS_IREFRESH", line 683
ORA-06512: at "SYS.DBMS_REFRESH", line 195
ORA-06512: at line 1
*** SESSION ID:(22.14163) 2007-09-15 23:37:18.810
*** 2007-09-15 23:37:18.810
ORA-12012: error on auto execute of job 50
ORA-12560: TNS:protocol adapter error
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 803
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 860
ORA-06512: at "SYS.DBMS_IREFRESH", line 683
ORA-06512: at "SYS.DBMS_REFRESH", line 195
ORA-06512: at line 1
Message was edited by:
Pravin Pawar -
How to CREATE MATERIALIZED VIEW LOG (MV fast refresh) with some JOINS
Hi @ all,
i'm trying to create a MATERIALIZED VIEW LOG for a fast refresh of a MATERIALIZED VIEW.
It works fine with a simple Request in the MATERIALIZED VIEW:
CREATE MATERIALIZED VIEW MV_ZOTD43_P
TABLESPACE GDII
BUILD IMMEDIATE
REFRESH FORCE AS
SELECT * FROM ZOTD43_P;
COMMIT;
CREATE MATERIALIZED VIEW LOG ON ZOTD43_P
TABLESPACE "GDII"
WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
call DBMS_MVIEW.REFRESH('MV_ZOTD43_P', 'f');
But when I use a complex SQL-Request with some JOINS (one of the Table with spatial Data) in the MATERIALIZED VIEW, I get an error:
CREATE MATERIALIZED VIEW MV_TEST
TABLESPACE GDII
BUILD IMMEDIATE
REFRESH FORCE AS
SELECT lptd04_p.sst_nr AS sst_nr,
lptd03_p.aaaa AS aaaa,
lptd04_geom.geom as geom
FROM lptd04_p lptd04_p
JOIN lptd01_p lptd01_p ON lptd01_p.cre_nr = lptd04_p.sst_nr
JOIN lptd04_geom ON lptd04_geom.sst_nr = lptd04_p.sst_nr
JOIN lptd03_p lptd03_p ON lptd03_p.lief_nr = lptd04_p.lief_nr;
COMMIT;
CREATE MATERIALIZED VIEW LOG ON LPTD04_P
TABLESPACE "GDII"
WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
call DBMS_MVIEW.REFRESH('MV_TEST', 'f');
Error report:
SQL Error: ORA-12004: REFRESH FAST kann für Materialized View "GDI"."MV_GDI_SST_STAMM" nicht benutzt werden
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2255
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2461
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2430
ORA-06512: in Zeile 1
12004. 00000 - "REFRESH FAST cannot be used for materialized view \"%s\".\"%s\""
*Cause: The materialized view log does not exist or cannot be used. PCT
refresh is also not enabled on the materialized view
*Action: Use just REFRESH, which will reinstantiate the entire table.
If a materialized view log exists and the form of the materialized
view allows the use of a materialized view log or PCT refresh is
possible after a given set of changes, REFRESH FAST will
be available starting the next time the materialized view is
refreshed.
Am I doing something wrong or is it not possible CREATE MATERIALIZED VIEW LOG when the MATERIALIZED VIEW got some JOINS?
Regards,
GreqThanks for the link Alessandro ,
the error seems something to do with the Column-Type SDO_GEOMETRY, so
i create a new thread in the Spatial Discussion forum:
FAST REFRESHing of Oracle Materialized Views containing SDO_GEOMETRY column
Regards,
Greq -
Materialized View and Redo Information
Hi!!
I have created a materialized view with fast refresh. I have created a materialized view log on master table with NOLOGING. My view is refresh every 3 seconds but My problem is that my archivelogs is now growing so much!!!
Please, How I avoid that redo information increasing so much?
Thank you,
Roxana.I want to show on line some tables of my database,
because I have created materialized view every 3
seconds on test enviroment. I'm not sure I follow exactly what you're saying here.
- Are you sure that you need materialized views here? And not just a regular view? If you need to display the data online and you need a lag of no more than three seconds, is there some reason that you're not using a regular old view? Are you doing some significant aggregation of the data?
- Are you sure that you need the materialized views to refresh every 3 seconds? And not on some longer interval?
- If you're looking for near real-time data replication, you may be better served by using Streams rather than materialized views.
When I use stand by database, I have to replica my
full database???.- I'm assuming this is a completely separate question with no relation to the previous section.
- Yes, DataGuard (physical or logical) would create and maintain a copy of your existing database on a separate server in order to fail over in the event of a disaster or to be a reporting server.
Justin -
Materialized view and Partition
Hi,
I want to discuss a scenario, with which i am dealing nowadays. there is only a single table (named livecdr ) has 22-23 fields and the records are updating in every sec (on daily basis) and in 24hrs livecdr contains approximately more than 2 crore records.
Problem is that the query processing time is so slow due to large number of records and query is fetching records from a view created on livecdr table. I want to know the options, how the query would fetch these records in a short time. Firstly i did range partitioning on livecdr and then i created materlized view but the view didn't create on partition table and when i removed partitioning it was created. After view creation, query performance is much better. i also applied indexing on livecdr.
Can you please tell me, whether this approach is okay or i am doing mistake. should i create partitioning on materialized view and how would i select records from view if partitioning would be applied on materialized view. Please guide me with best approaches.
thankyou.Hello,
Here is how I created partitioned table (monthly partitions) and partitioned mview on the table. This is just an example you might have to change the mview partitions from monhtly to yearly or quartely.
CREATE TABLE live_cdr
CALLID VARCHAR2 (20),
CD VARCHAR2 (25),
CG VARCHAR2 (25),
RE VARCHAR2 (25),
OPC VARCHAR2 (12),
DPC VARCHAR2 (12),
STIME VARCHAR2 (25),
SDATE DATE,
ATIME VARCHAR2 (25),
ADATE DATE,
ETIME VARCHAR2 (25),
EDATE DATE,
schangeTime VARCHAR2 (25),
schangeDate DATE,
STATUS VARCHAR2 (25),
bucket NUMBER (20),
CIC NUMBER (20),
charge VARCHAR2 (30),
ported VARCHAR2 (30),
jurisdiction_Info VARCHAR2 (30),
origLine_Info CHAR (1),
Variant NUMBER,
auto_inc NUMBER
PARTITION BY RANGE (EDATE)
PARTITION LIVE_CDR_JAN_2009 VALUES LESS THAN (TO_DATE(' 2009-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS,
PARTITION LIVE_CDR_FEB_2009 VALUES LESS THAN (TO_DATE(' 2009-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
);Mview definition
CREATE MATERIALIZED VIEW KLONDIKE.LIVE_CDR_MV
LOGGING
PARTITION BY RANGE (EDATE)
PARTITION LIVE_CDR_MV_JAN_2009 VALUES LESS THAN (TO_DATE('20090201',
'YYYYMMDD'))
LOGGING
NOCOMPRESS,
PARTITION LIVE_CDR_MV_FEB_2009 VALUES LESS THAN (TO_DATE('20090301',
'YYYYMMDD'))
LOGGING
NOCOMPRESS
BUILD IMMEDIATE
REFRESH COMPLETE
START WITH SYSDATE
NEXT SYSDATE + 2 /24
AS
SELECT DISTINCT (ic.callid) callid,
ic.CG,
ic.CD,
ic.RE,
ic.OPC,
ic.DPC,
ic.SDATE,
ic.STIME,
ac.ADATE,
ac.ATIME,
ec.ETIME,
ec.EDATE,
ec.STATUS
FROM live_cdr ic, live_cdr ac, live_cdr ec
WHERE ic.callid = ac.callid
AND ic.callid = ec.callid
AND ic.stime = ac.stime
AND ic.stime = ec.stime
AND ic.sdate = ac.sdate
AND ic.sdate = ec.sdate
AND ac.ADATE IS NOT NULL
AND ec.EDATe IS NOT NULL
AND ec.etime IS NOT NULL
AND ic.CD IS NOT NULL
AND ic.cg IS NOT NULL;Regards -
Materialized view with refresh frequency of once every day
DB Version:11g
If i want to create a Materialized view which should get refreshed once every day, the below code should be fine. Right
create materialized view mv_empname refresh complete
start with sysdate
next sysdate + 1
as select empname from emp Should i be using TRUNC
like
next trunc(sysdate) + 1 for any reason?If you dont use TRUNC i guess it will be refreshed every day at the time when it was first refreshed. That is If first time it was refreshed on 3pm then ever day it will be refreshed at 3pm.
But when you user TRUNC you are removing the time part and it will be set to 00:00:00 meaning 12AM. so the refresh will happen at 12AM ever day. -
MATERIALIZED VIEW and MATERIALIZED VIEW LOG
Hello,
I have the following table
create table My_price
(price_id number(10),
product_id number(10),
price_date date,
price_value number(10,2));
I want to create the following materialized view
create materialized view Last_Price_Date
refresh
on commit complete
as
select max(price_date) as max_date, product_id from my_price group by product_id;
Do I have to create materialized view log ? Will my materialized view be refresh on commit without materialized view log ?As a student the requisite first task is always to study. Thus your assignment is to go to http://tahiti.oracle.com and read the concept and architecture docs on Materialized Views so that you can learn about the different types of MVs and how and when they are refreshed. There you will learn about what ON COMMIT means.
Then please turn your "I want to create" into an "I created it." Then, having read the docs, you will be able to observe how your MV behaves.
PS: Your SELECT statement is not syntactically correct. Start by fixing it so that it works in SQL*Plus. -
Updatable Materialized View and Master Table on same database
Hi all,
My first question - Is it possible to have an Updatable Materialized View and the associated Master Table located on the same database?
This is the requirement scenario:
One unique database D exists.
A is a batch table. Only inserts are allowed on Table A.
M is an updatable materialized view on Table A (Master). Only updates are allowed on M (no insert or delete).
Requirement is to push updates/changes from M to A periodically and then get the new inserted records from A into M via a refresh.
Is this possible? What other approaches are applicable here?John,
My question is related to the implementation and setup of the environment as explained in the above example. How can I achieve this considering that I have created an updatable m-view?
If possible, how do I push changes made to an updatable m-view back to it's master table when/before I execute DBMS_MVIEW.REFRESH on the m-view? What is the procedure to do this if both table and mview exist on the same database? Do I need to create master groups, materialized view refresh groups, etc.?
One more thing.. Is there a way to retain changes to the m-view during refresh? In this case, only newly inserted/updated records in the associated table would get inserted into m-view. Whereas changes made to m-view records would stay as-is.
Hope my question is directed well. Thanks for your help.
- Ankit -
Materialized View and I_SNAP$ Indexes
Hello Everybody,
At the time of doing REFRESH of the Materialized View, we are getting error like -
SQL> EXECUTE DBMS_MVIEW.REFRESH('MV_TEST.MY_VIEW,'CF');
BEGIN DBMS_MVIEW.REFRESH('MV_TEST.MY_VIEW,'CF'); END;
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-00001: unique constraint (MV_TEST.I_SNAP$_FIN_RESULT_EXPENSE1) violated
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2545
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2751
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2720
ORA-06512: at line 1
I tried to drop and recreate the index I_SNAP$_FIN_RESULT_EXPENSE1 but it didn’t helped.
Later I dropped the index I_SNAP$_FIN_RESULT_EXPENSE1 and refreshed the materialized view and it was successful (obvious). But when I tried to recreate the index, I got the following error –
SYS_OP_MAP_NONNULL("FIN_MULT"), SYS_OP_MAP_NONNULL("FIN_CD"))
ERROR at line 8:
ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
When I look at the value of SYS_OP_MAP_NONNULL('FIN_CD'), it seems to be unique.
SQL> select SYS_OP_MAP_NONNULL('FIN_CD') from dual;
SYS_OP_MAP_NONNULL('FIN_CD’)
46494E5F5650545F4C564C5F335F434400
My questions are:
1. Why are the indexes (I_SNAP$_*) automatically created for?
2. What is the purpose of these (I_SNAP$_*) indexes?
3. What harm can be there if we drop these (I_SNAP$_*) indexes?
4. Why it is complaining about the Duplicate records / Uniqueness?
5. How to know where exactly the problem is in this case?
6. What is the solution for this problem? How to recreate these indexes successfully?
Thanks!Hello Rafi,
I don't have any MLOG$_<table> in the database, After connecting as SYS -
SQL> select tname from tab where tname like '%MLOG%';
TNAME
MLOG_REFCOL$
MLOG$
C_MLOG#
SQL> select count(*) from mlog$;
COUNT(*)
0
I am not using Replication here -
SQL> select tname from tab where tname like '%RUPD%';
no rows selected
Why you think that granting SELECT access to MLOG$_* tables will solve this issue?
Thanks,
Roopesh -
Materialized view and snapshot
Hi gurus,
Could you please tell me what is the difference between materialized view and snapshot.
Regards
KoustavA snapshot, is in general terms, a picture, a click of a camera, an image that captures the position/state of something at sometime.
Snapshot in a database can take many points of view.
Materialized view (MV) is an object in Oracle database. It "materializes" a view, by taking a snapshot, of the view when you actually create the MV, and preserve it for future use. It can be refreshed in several available ways.
A view doesn't occupy any space, a MV does.
HTH,
Aswin. -
Materialized View and Ord Media questions
Hey Guys,
My first question is on the use and creation of materialized views which i have previously done using TOAD. The question that i have is where/if can i visually see the constraints that are on a materialized view and where is the information for "next refresh" times placed?
Question two is about viewing informaiton on ord media objects that are stored. Previously, i had the ability to double click one of these elememts in the data view and see the information related to that instance of the ord media object, but the SQL developer does not seem to have this ability??
Thanks in advance.Thanks Kris,
The reason that i asked about the constraints on MV is because when you create a materialized view over a db link with primary key, it will place a not null constraint on every column. This is obviously no good because some rows are bound to contain nulls and these need to be removed and updated before it will work!
As for the ord objects, it just makes it a little easier for testing to see what they are :).
Anyway, its looking great and i hope these features will be in the next release?
Cheers David -
Materialized view and policies
Hello,
We created an materialized view and on this view why created a policy.
SYS.DBMS_RLS.ADD_POLICY
Now we added some values to the MV via drop MV and create MV.
The policy on this MV is gone after the drop statement.
Is there away to secure this?
Thanks,
RemcoWhy are you dropping and re-creating the materialized view in the first place? That's not something that should ever happen in a live system. You should just be refreshing the data in the materialized view, in which case the privileges & policies associated with the materialized view would be retained. It's no different than dropping and re-creating a table that has a policy associated with it-- you'd have to re-apply the policy after re-creating the table.
Theoretically, I suppose you could create a DDL trigger that would throw an error if you tried to drop an object with an associated policy. Fixing your approach, though, so that you're not dropping & re-creating objects is going to be the better long-term solution.
Justin
Maybe you are looking for
-
Java update does not installcorrectly on my mac and chat is intermittent in all games Cannot play crosswords because no letters type in squares. Can anyone help with this issue?
-
FileInputStream and empty directories
How can I read an empty directory to a byte array? I'm currently reading it like this: in = new BufferedInputStream(new FileInputStream(aux)); int len; while ((len = in.read(buffer)) > 0) out.write(buffer, 0, len);Thanx in advance! :)
-
Possible to host a forum on Apple Server?
Is there any software to host a forum on my Apple server? Is there any advantage to doing so, or is there a free public forum provider people would recommend for hosting a small (low-traffic) forum for my laboratory? thanks Mike
-
Button click handler using values through UDPClient
I am making a BCI system for my master thesis, and I am new to C#, so I would like to know if it is possible to click a button through a value obtained though a fx UDP client. What I wloud like to do : Acquirer data through MATALB -> send the data to
-
How do you fix error -3256 when trying to put ios 5 on my phone?
How do you fix error -3256 when trying to put ios 5 on my phone? I have a mac. I have backed up everything....?