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.
Similar Messages
-
Materialized View Fast Refresh encounters 2164 BUILD DEFERRED
I have a materialized view with REFRESH FAST ON DEMAND. The related tables have the required MV Logs and the FAST refresh usually works, but occasional it does not. When it does not there is NO error when DBMS_MVIEW.REFRESH with an F is executed, but the MV is no longer used for QUERY REWRITE. When I run DBMS_MVIEW.EXPLAIN_MVIEW for the MV, I get MSGNO 2164 with MSGTXT 'the materialized view is BUILD DEFERRED'. When I run DBMS_MVIEW.EXPLAIN_REWRITE for a query which used this MV for query rewrite, I get 'QSM-01219: no suitable materialized view found to rewrite this query'.
I have not been able to find any information on the 2164 message nor have I been able to understand why this happens sometimes and not other times.
Oracle 11.2.0.2
Any help in either resolving the error or a method to further research it would be greatly appreciated.
Thanks!I'd like to clarify that the issue I am seeing is NOT the the query will not rewrite. It rewrites perfectly when the MV is in a good state. The problem is that during certain refreshes of the MV a 2164 occurs and I get the message that the query is 'BUILD DEFERRED'. No error comes up during refresh, but when I run DBMS_MVIEW.EXPLAIN_MVIEW and query the MV_CAPABILITIES_TABLE I see the 2164.
Thanks for everyone's help in trying to get this solved. -
Fast refresh of "materialized view with joins only"
Hi,
My Requirement:
I need to create a materialized view joining two tables.
Table1 -> Does not have primary key
Table2 -> Has a primary key
I need to refesh the mat view only when DML commands are done on Table1 alone.
And it will be better if i have a Refresh on commit rather on demand.
The following code is what i used and it dint work for me:
CREATE MATERIALIZED VIEW LOG ON Table1 WITH ROWID;
CREATE MATERIALIZED VIEW LOG ON Table2;
CREATE MATERIALIZED VIEW AAYT_ETF
REFRESH FORCE ON COMMIT
ENABLE QUERY REWRITE
AS
SELECT A.rowid "table1_rowid", A.ACCTNUM, A.CORR_NUM, A.OFC_NUM, A.RR_NUM, A.BUY_SELL_CDE, A.ACT_AMT, A.CSP_SYM, A.SECR_DESC, A.ACT_QTY
FROM Table1 A, Table2 G WHERE
A.CSP_NUM = G.CSP_NUM AND
G.ASST_SUB_STYP = 'ETF';
Issue Faced: In this case the refresh happends even while i do DML on Table2.
But i need the refresh only when i do DML on Table1. I also unable to create Refresh Fast Mat view.
Can anyone please tell me how to create the Materialized view Log and the Materialized view. Thanks in advance.This forum only is for questions relating to the use of OLAP Option. I would post your question on the database forum.
Keith Laker
Oracle Data Warehouse Product Management
OLAP Blog: http://oracleOLAP.blogspot.com/
OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
DM Blog: http://oracledmt.blogspot.com/
OWB Blog : http://blogs.oracle.com/warehousebuilder/
OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html -
Create a fast refresh materialized view with partitioned primary index
Hi,
I have a materialized view that is based on a table with primary key.
I want to create a materialized view with a partitioned primary index . do you have any way of doing it?
I tried to create a materialized view with rowid and then I created a partitioned primary index on it.
It did not work as what I expected. I could not perform a fast refresh on it. the materialized view can only complete refresh
thank youHi,
Here is some info from the Oracle Documentation.
http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm
http://download.oracle.com/docs/cd/E11882_01/server.112/e10810/basicmv.htm
Determining the Fast Refresh Capabilities of a Materialized View
http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#BABEDIAH
Regards, -
Materialized view with date range
hey,
i have a Statistics Query with start date and end date and its Table table_a would be refreshed every hour....:
e.g.
select ...
from table_a a, table_b b ....
where table_a.transactiondate between start_date and end_date and ....;
So I am wondering how to create a effective materialized view? This is a big query with mutilple tables and each table has many rows.
I have tried to use:
create materialized view view_a
refresh fast
start with sysdate next sysdate + 1/24
as
select a.start_date, a.end_date, ....
from table_a a, table_b b ....
where ....;
Thanks.If you want to use FAST REFRESH, you must create a MV Log. It would be something like this:
create materialized view log on TABLE
with primary key including new values
create materialized view mv_TABLE
refresh fast
start with sysdate next sysdate + 1/24
as select * from TABLE
For more info about MV:
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_6002.htm
Hope I've helped!
Regards,
Marcos -
Regarding Error in Materialized view Fast Refresh
ORA-12015: cannot create a fast refresh materialized view from a complex query
CREATE MATERIALIZED VIEW MVCONTENTHISTORY_01
BUILD IMMEDIATE
REFRESH FAST
WITH PRIMARY KEY
ENABLE QUERY REWRITE
AS
SELECT a.DAY, a.contentname,
SUM
(CASE
WHEN (b.subscriptionstartdate) <= (a.DAY)
AND ((CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (a.DAY)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
) <=
(CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (b.subscriptionenddate)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
THEN 1
ELSE 0
END
) COUNT,
COUNT
(CASE
WHEN (b.subscriptionstartdate) <= (a.DAY)
AND ((CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (a.DAY)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
) <=
(CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (b.subscriptionenddate)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
THEN 1
ELSE 0
END
) cnt
FROM TBLTDATEWISECONTENT a,
(SELECT TRUNC (a.subscriptionstartdate) subscriptionstartdate,
TRUNC (a.subscriptionenddate) subscriptionenddate, b.NAME,
b.contentid
FROM syntbltcontentsubscrhistory a, syntblmcontent b
WHERE b.contentid = a.contentid(+)) b
WHERE a.contentid = b.contentid(+) AND a.DAY = b.subscriptionstartdate(+)
GROUP BY a.contentname, a.DAY;
I can't create Materialized view with fast Refresh .
Kindly provide solution .
Regards,
nayana chavda.Kindly provide full Oracle version since option vary by release.
There error message says it is impossible to fast refresh based on a complex query.
On 10g Oracle provides a package procedure that will tell you why the view cannot be fast refreshed: dbms_mview.explain_mview.
Otherwise see the Advanced Replication Manual for a list of restrictions.
10gR2 >>Restrictions for Materialized Views with Subqueries
The defining query of a materialized view with a subquery is subject to several restrictions to preserve the materialized view's fast refresh capability.
The following are restrictions for fast refresh materialized views with subqueries:
Materialized views must be primary key materialized views.
The master's materialized view log must include certain columns referenced in the subquery. For information about which columns must be included, see "Logging Columns in the Materialized View Log".
If the subquery is many to many or one to many, join columns that are not part of a primary key must be included in the materialized view log of the master. This restriction does not apply to many to one subqueries.
The subquery must be a positive subquery. For example, you can use the EXISTS condition, but not the NOT EXISTS condition.
The subquery must use EXISTS to connect each nested level (IN is not allowed).
Each table can be in only one EXISTS expression.
The join expression must use exact match or equality comparisons (that is, equi-joins).
Each table can be joined only once within the subquery.
A primary key must exist for each table at each nested level.
Each nested level can only reference the table in the level above it.
Subqueries can include AND conditions, but each OR condition can only reference columns contained within one row. Multiple OR conditions within a subquery can be connected with an AND condition.
All tables referenced in a subquery must reside in the same master site or master materialized view site.
<<
HTH -- Mark D Powell --
Message was edited by: added list of restrictions left off initial post
mpowel01 -
Updatable Materialized View with Union ALL
(please don't ask about db structure)
DB: 11gR2
create table table_1 (
id number primary key,
val varchar2(100)
create table table_2 (
id number primary key,
val varchar2(100)
insert into table_1(id) values (0);
insert into table_1(id) values (2);
insert into table_1(id) values (3);
insert into table_1(id) values (4);
insert into table_1(id) values (5);
insert into table_2(id) values (10);
insert into table_2(id) values (12);
insert into table_2(id) values (13);
insert into table_2(id) values (14);
insert into table_2(id) values (15);
update table_1 set val='Table1 val:'||id;
update table_2 set val='Table2 val:'||id;
create view v_table_all as
select * from table_1
view V_TABLE_ALL created.
select * from v_table_all;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 Table1 val:3
4 Table1 val:4
5 Table1 val:5
select column_name, updatable, insertable, deletable
from user_updatable_columns
where table_name = 'V_TABLE_ALL'
COLUMN_NAME UPDATABLE INSERTABLE DELETABLE
ID YES YES YES
VAL YES YES YES
update v_table_all set val='XXX changed' where id = 3;
1 row updated.
select * from table_1;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 XXX changed
4 Table1 val:4
5 Table1 val:5
rollback;
select * from table_1;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 Table1 val:3
4 Table1 val:4
5 Table1 val:5
create or replace view v_table_all as
select * from table_1
union select * from table_2;
view V_TABLE_ALL created.
select * from v_table_all;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 Table1 val:3
4 Table1 val:4
5 Table1 val:5
10 Table2 val:10
12 Table2 val:12
13 Table2 val:13
14 Table2 val:14
15 Table2 val:15
select column_name, updatable, insertable, deletable
from user_updatable_columns
where table_name = 'V_TABLE_ALL'
COLUMN_NAME UPDATABLE INSERTABLE DELETABLE
ID NO NO NO
VAL NO NO NO
trying update:
update v_table_all set val='XXX changed' where id = 3;
SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
01732. 00000 - "data manipulation operation not legal on this view"
*Cause:
*Action:
drop view v_table_all;
view V_TABLE_ALL dropped.all is ok before this point.
now we want create a new materialized view with some query
create materialized view v_table_all
as
select * from table_1
union all select * from table_2 ;
materialized view V_TABLE_ALL created.
select column_name, updatable, insertable, deletable
from user_updatable_columns
where table_name = 'V_TABLE_ALL'
COLUMN_NAME UPDATABLE INSERTABLE DELETABLE
ID YES YES YES
VAL YES YES YES it seems to be ok with update.
but...
update v_table_all set val='XXX changed' where id = 3;
SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
01732. 00000 - "data manipulation operation not legal on this view"
*Cause:
*Action:How can solve this issue??
Any suggestionLooks like user_updatable_columns sort of thinks the MV is just a table - I don't know about that...
An MV on a single table can be updated - I tried that and it works:
create materialized view mv_table_1 for update
as
select * from table_1;I noticed [url http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/advmv.htm#sthref294]examples stating the UNION ALL needs a "marker" so Oracle can know from the data which source table a row in the MV originates from - like this:
create materialized view v_table_all for update
as
select 'T1' tab_id, table_1.* from table_1
union all
select 'T2' tab_id, table_2.* from table_2 ;But that also fails (the "marker" requirement was specifically for FAST REFRESH, so it was just a long shot ;-) )
What are you planning to do?
<li>Create the MV.
<li>Update records in the MV - which then is no longer consistent with the source data.
<li>Schedule a complete refresh once in a while - thereby overwriting/losing the updates in the MV.
If that is the case, I suggest using a true table rather than an MV.
<li>Create table t_table_all as select ... .
<li>Update records in the table - which then is no longer consistent with the source data.
<li>Schedule a job to delete table and insert into table select ... once in a while - thereby overwriting/losing the updates in the table.
In other words a kind of "do it yourself MV".
I cannot see another way at the moment? But perhaps try in the data warehousing forum - the people there may have greater experience with MV's ;-) -
Creating materialized view with variables - help
Greetings,
I want to create an materialized view (MV) from the external public db link. Below is my full query:
CREATE MATERIALIZED VIEW PROJECTS_MV
REFRESH WITH ROWID
AS
SELECT prj.Project_id, prj.desc,
prj.parent_project_id, f_year, f_month
FROM sysadm.prj@EFUYEEDW_DB_LINK.MSDB prj
WHERE prj.pf_scenario_id = '708KDD'
AND prj.ph_id = 'SHAREDP'
AND f_year = (SELECT EXTRACT(year FROM current_DATE) FROM dual)
AND f_month = (SELECT EXTRACT(month FROM current_DATE) FROM dual)
Question: In the query there are two variables that capture the month and year and requery it. Does the data get updated automatically when a new month or new year changes?
If there is a change, how would I change so it would update the data accordingly?
Thanks for your help
john9569Hi Christian,
Thanks for your response. Your codes return the date as 01-JAN-09 which is not what I'm looking for. Maybe my question is not clear.
So far, the MV is executed correctly what I want. My concern is when it updates the MV, does it get the new data (f_month & f_year) when the MV is updated automatically?
Other words, the MV is updated nightly to get the incremental data from the db link. Once it passes to the new month, I am not sure how this MV handles since the f_month is now changed to differrent number.
Thanks for your help.
Bests,
John9569 -
Materialized View with Sequence
Please help!!
I was wondering if anyone knows how to create a MATERIALIZED VIEW with a generating sequence number (sequence.nextval)???
This is sort of what I want but it doesn't work:
create materialized view ORACLE_AUDIT_LOG_MVW
refresh force start with sysdate
next sysdate + 1
with primary key
as select oracle_seq.nextval,
'Auditing Information' title,
ses.tnsname,
o.obj_owner,
o.obj_name,
o.action_name,
ses.os_username,
ses.username,
ses.machine as machine,
ses.program,
ses.module,
ses.client_ip,
ses.connection_msg,
to_char(ses.logon_time,'DD-MON-YY HH:MM:SS'),
to_char(ses.logoff_time,'DD-MON-YY HH:MM:SS')
from audit_sessions ses, audit_objects o
where ses.tnsname = o.tnsname
and ses.sessionid = o.sessionid
GROUP BY ses.tnsname, O.SESSIONID, o.obj_owner, o.obj_name, o.action_name, ses.os_username, ses.username, ses.machine, ses.program, ses.module, ses.client_ip, ses.connection_msg, ses.logon_time, ses.logoff_time
UNION all
select oracle_seq.nextval,
'Failed Logons' title,
fl.tnsname,
fl.os_username,
fl.username,
fl.terminal as terminal,
fl.connection_msg,
to_char(fl.logon_time,'DD-MON-YY HH:MM:SS'),
from audit_failed_logons fl
Can someone PPPLLLLEEEAAAASSSEE help me???
Thanks so much,
Mary LeeFirst, "doesn't work" isn't particularly descriptive. Error numbers and error messages would be very helpful.
Second, does it have to be a sequence value? Could you not use either ROWNUM or one of the analytic functions (RANK, DENSE_RANK, ROW_NUMBER, etc)?
Third, you'll almost certainly need this MV to be completely refreshed every time...
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Oracle 9i Rel2 Materialized View Fast refresh
Hi,
I have created materialized view with join and aggregation of four tables.
For complete refresh it takes 30 minutes, but for a fast
refresh it is taking 4 hours.
Why this much time it should take for a fast refresh.
Any suggestions will be highly helpful
Regards
Paddy
The following are the scripts
CREATE MATERIALIZED VIEW LOG ON RISK_REPORT_CACHE_1 TABLESPACE FLASH_DATA_M
WITH SEQUENCE, ROWID
( VALUE_DATE, IS_OFFICIAL, POSID,
REF_TYPE, REF_ID, INDUSTRY,
COUNTRY, RATING, RANKING,
DESCRIPTION, TICKER, SENDER,
BOOK, CENTER, CURR,
RISKTYPE, TENOR, SENSI,
NOTIONAL, FXRATE, OECDFACTOR,
MSFACTOR, EMFACTOR, MKTVAL,
PARAMT, ISSR_RISK, AGE,
ACQ_DATE, SYS_BOOK, EXCLUDED,
REF_FLASH_ID, ENTITY_ID, PARENT_ENTITY_ID,
YELLOW_KEY, PARENT_DESC, STRESS,
VOLAT, PRD_TYPE, POS_DESC,
BBG_INDUSTRY_SECTOR, BBG_INDUSTRY_GROUP, COUNTRY_RATING
) INCLUDING NEW VALUES ;
PROMPT TO CREATE THE MV LOG ON FLASH_COUNTRY
CREATE MATERIALIZED VIEW LOG ON FLASH_COUNTRY TABLESPACE FLASH_DATA_M
WITH SEQUENCE, ROWID
( ISO , COUNTRY , CURRENCY,
MF_CONSOL, ENTITY_ID, REGION
) INCLUDING NEW VALUES ;
PROMPT TO CREATE THE MV LOG ON PF_HIERARCHY_CACHE
CREATE MATERIALIZED VIEW LOG ON PF_HIERARCHY_CACHE TABLESPACE FLASH_DATA_M
WITH SEQUENCE, ROWID
ID_1 , NAME_1 , DESC_1 , PERM_1 ,
ID_2 , NAME_2 , DESC_2 , PERM_2 ,
ID_3 , NAME_3 , DESC_3 , PERM_3 ,
ID_4 , NAME_4 , DESC_4 , PERM_4 ,
ID_5 , NAME_5 , DESC_5 , PERM_5 ,
ID_6 , NAME_6 , DESC_6 , PERM_6 ,
ID_7 , NAME_7 , DESC_7 , PERM_7 ,
ID_8 , NAME_8 , DESC_8 , PERM_8 ,
ID_9 , NAME_9 , DESC_9 , PERM_9 ,
ID_10 , NAME_10, DESC_10, PERM_10,
SYSTEM, BOOK , SYS_BOOK, MAX_LVL,
LAST_UPDATED
) INCLUDING NEW VALUES ;
PROMPT TO CREATE THE MV LOG ON MAP_PRDTYPE_TO_DEALTYPE
CREATE MATERIALIZED VIEW LOG ON MAP_PRDTYPE_TO_DEALTYPE TABLESPACE FLASH_DATA_M
WITH SEQUENCE, ROWID
( PRD_TYPE, DEAL_TYPE
) INCLUDING NEW VALUES ;
PROMPT TO CREATE THE MATERIALIZED VIEW
PROMPT MV_AGG_RISK_REPORT_CACHE_SBOOK
CREATE MATERIALIZED VIEW MV_AGG_RISK_REPORT_CACHE_SBOOK
TABLESPACE FLASH_DATA_M
PARALLEL
PARTITION BY RANGE(VALUE_DATE)
(PARTITION P20040113 VALUES LESS THAN (TO_DATE(' 2004-01-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040227 VALUES LESS THAN (TO_DATE(' 2004-02-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040304 VALUES LESS THAN (TO_DATE(' 2004-03-05 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040305 VALUES LESS THAN (TO_DATE(' 2004-03-06 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040306 VALUES LESS THAN (TO_DATE(' 2004-03-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040307 VALUES LESS THAN (TO_DATE(' 2004-03-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040308 VALUES LESS THAN (TO_DATE(' 2004-03-09 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040309 VALUES LESS THAN (TO_DATE(' 2004-03-10 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040310 VALUES LESS THAN (TO_DATE(' 2004-03-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040311 VALUES LESS THAN (TO_DATE(' 2004-03-12 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040312 VALUES LESS THAN (TO_DATE(' 2004-03-13 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040313 VALUES LESS THAN (TO_DATE(' 2004-03-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040314 VALUES LESS THAN (TO_DATE(' 2004-03-15 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040315 VALUES LESS THAN (TO_DATE(' 2004-03-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040316 VALUES LESS THAN (TO_DATE(' 2004-03-17 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040317 VALUES LESS THAN (TO_DATE(' 2004-03-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040318 VALUES LESS THAN (TO_DATE(' 2004-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040319 VALUES LESS THAN (TO_DATE(' 2004-03-20 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040320 VALUES LESS THAN (TO_DATE(' 2004-03-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040321 VALUES LESS THAN (TO_DATE(' 2004-03-22 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040322 VALUES LESS THAN (TO_DATE(' 2004-03-23 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040323 VALUES LESS THAN (TO_DATE(' 2004-03-24 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040324 VALUES LESS THAN (TO_DATE(' 2004-03-25 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040325 VALUES LESS THAN (TO_DATE(' 2004-03-26 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040326 VALUES LESS THAN (TO_DATE(' 2004-03-27 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040327 VALUES LESS THAN (TO_DATE(' 2004-03-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040328 VALUES LESS THAN (TO_DATE(' 2004-03-29 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040329 VALUES LESS THAN (TO_DATE(' 2004-03-30 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040330 VALUES LESS THAN (TO_DATE(' 2004-03-31 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040331 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040401 VALUES LESS THAN (TO_DATE(' 2004-04-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040402 VALUES LESS THAN (TO_DATE(' 2004-04-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040403 VALUES LESS THAN (TO_DATE(' 2004-04-04 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040404 VALUES LESS THAN (TO_DATE(' 2004-04-05 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040405 VALUES LESS THAN (TO_DATE(' 2004-04-06 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040406 VALUES LESS THAN (TO_DATE(' 2004-04-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040407 VALUES LESS THAN (TO_DATE(' 2004-04-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040408 VALUES LESS THAN (TO_DATE(' 2004-04-09 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040409 VALUES LESS THAN (TO_DATE(' 2004-04-10 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040410 VALUES LESS THAN (TO_DATE(' 2004-04-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040411 VALUES LESS THAN (TO_DATE(' 2004-04-12 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040412 VALUES LESS THAN (TO_DATE(' 2004-04-13 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040413 VALUES LESS THAN (TO_DATE(' 2004-04-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040414 VALUES LESS THAN (TO_DATE(' 2004-04-15 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040415 VALUES LESS THAN (TO_DATE(' 2004-04-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040416 VALUES LESS THAN (TO_DATE(' 2004-04-17 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040417 VALUES LESS THAN (TO_DATE(' 2004-04-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040418 VALUES LESS THAN (TO_DATE(' 2004-04-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040419 VALUES LESS THAN (TO_DATE(' 2004-04-20 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040420 VALUES LESS THAN (TO_DATE(' 2004-04-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040421 VALUES LESS THAN (TO_DATE(' 2004-04-22 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M
BUILD IMMEDIATE
USING INDEX TABLESPACE FLASH_INDX_M
REFRESH FAST ON DEMAND
ENABLE QUERY REWRITE
AS
SELECT
RRC.VALUE_DATE VALUE_DATE,
PHC.NAME_4 NAME_4,
PHC.NAME_5 NAME_5,
PHC.NAME_6 NAME_6,
PHC.NAME_7 NAME_7,
PHC.BOOK BOOK,
PHC.SYS_BOOK SYS_BOOK,
RRC.CURR CURR,
RRC.INDUSTRY INDUSTRY,
RRC.BBG_INDUSTRY_GROUP BBG_INDUSTRY_GROUP,
RRC.BBG_INDUSTRY_SECTOR BBG_INDUSTRY_SECTOR,
RRC.COUNTRY COUNTRY,
FC.REGION REGION,
RRC.COUNTRY_RATING COUNTRY_RATING,
RRC.RISKTYPE RISKTYPE,
RRC.TENOR TENOR,
RRC.TICKER TICKER,
RRC.DESCRIPTION DESCRIPTION,
RRC.RATING RATING,
RRC.FXRATE FXRATE,
RRC.POS_DESC POS_DESC,
MPTD.DEAL_TYPE DEAL_TYPE,
SUM(PHC.MAX_LVL) MAX_LVL,
COUNT(PHC.MAX_LVL) PHC_seqnum,
COUNT(*) CNT,
SUM(DECODE(RRC.RISKTYPE,
'GOVT',SENSI,0)) GOVT_DELTA ,
SUM(DECODE(RRC.RISKTYPE,
'LIBOR',SENSI,0)) LIBOR_DELTA,
SUM(DECODE(RRC.RISKTYPE,
'CREDIT',SENSI,0)) CREDIT_DELTA,
SUM(DECODE(RRC.RISKTYPE,
'GOVT',SENSI,
'LIBOR',SENSI,0)) MARKET_DELTA,
SUM(DECODE(RRC.RISKTYPE,
'GOVT',STRESS,0)) GOVT_STRESS,
SUM(DECODE(RRC.RISKTYPE,
'LIBOR',STRESS,0)) LIBOR_STRESS,
SUM(DECODE(RRC.RISKTYPE,
'CREDIT',STRESS,0)) CREDIT_STRESS,
SUM(DECODE(RRC.RISKTYPE,
'GOVT',STRESS,
'LIBOR',STRESS,0)) MARKET_STRESS,
SUM(DECODE(RRC.RISKTYPE,
'GOVT',STRESS,
'LIBOR',STRESS,
'CREDIT',STRESS,0)) TOTAL_STRESS,
SUM(VOLAT) VOLAT,
SUM(MKTVAL) MKTVAL,
COUNT(DECODE(RRC.RISKTYPE,
'GOVT',SENSI,0)) CNT_GOVT_DELTA ,
COUNT(DECODE(RRC.RISKTYPE,
'LIBOR',SENSI,0)) CNT_LIBOR_DELTA,
COUNT(DECODE(RRC.RISKTYPE,
'CREDIT',SENSI,0)) CNT_CREDIT_DELTA,
COUNT(DECODE(RRC.RISKTYPE,
'GOVT',SENSI,
'LIBOR',SENSI,0)) CNT_MARKET_DELTA,
COUNT(DECODE(RRC.RISKTYPE,
'GOVT',STRESS,0)) CNT_GOVT_STRESS,
COUNT(DECODE(RRC.RISKTYPE,
'LIBOR',STRESS,0)) CNT_LIBOR_STRESS,
COUNT(DECODE(RRC.RISKTYPE,
'CREDIT',STRESS,0)) CNT_CREDIT_STRESS,
COUNT(DECODE(RRC.RISKTYPE,
'GOVT',STRESS,
'LIBOR',STRESS,0)) CNT_MARKET_STRESS,
COUNT(DECODE(RRC.RISKTYPE,
'GOVT',STRESS,
'LIBOR',STRESS,
'CREDIT',STRESS,0)) CNT_TOTAL_STRESS,
COUNT(VOLAT) CNT_VOLAT,
COUNT(MKTVAL) CNT_MKTVAL
FROM RISK_REPORT_CACHE_1 RRC,
FLASH_COUNTRY FC,
PF_HIERARCHY_CACHE PHC,
MAP_PRDTYPE_TO_DEALTYPE MPTD
WHERE RRC.SYS_BOOK = PHC.SYS_BOOK
AND RRC.COUNTRY = FC.COUNTRY
AND PHC.NAME_1 = 'MRC - FIRC III'
AND PHC.NAME_2 = 'Fixed Income'
AND PHC.NAME_3 = 'Investment Grade, High Yield and Emerging Markets'
AND MPTD.PRD_TYPE = RRC.PRD_TYPE
GROUP BY
RRC.VALUE_DATE,
PHC.NAME_4,
PHC.NAME_5,
PHC.NAME_6,
PHC.NAME_7,
PHC.BOOK,
PHC.SYS_BOOK,
RRC.CURR,
RRC.INDUSTRY,
RRC.BBG_INDUSTRY_GROUP,
RRC.BBG_INDUSTRY_SECTOR,
RRC.COUNTRY,
FC.REGION,
RRC.COUNTRY_RATING,
RRC.RISKTYPE,
RRC.TENOR,
RRC.TICKER,
RRC.DESCRIPTION,
RRC.RATING,
RRC.FXRATE,
RRC.POS_DESC,
MPTD.DEAL_TYPE;
PROMPT TO CREATE THE MV LOG ON MV_AGG_RISK_REPORT_CACHE_SBOOK
CREATE MATERIALIZED VIEW LOG ON MV_AGG_RISK_REPORT_CACHE_SBOOK TABLESPACE FLASH_DATA_M
WITH ROWID
( VALUE_DATE , NAME_4 , NAME_5 , NAME_6,
NAME_7 , BOOK , SYS_BOOK , CURR,
INDUSTRY , BBG_INDUSTRY_GROUP, BBG_INDUSTRY_SECTOR, COUNTRY,
COUNTRY_RATING , RISKTYPE , TENOR , TICKER,
DESCRIPTION , RATING , FXRATE , DEAL_TYPE,
GOVT_DELTA , LIBOR_DELTA , CREDIT_DELTA , MARKET_DELTA,
GOVT_STRESS , LIBOR_STRESS , CREDIT_STRESS , MARKET_STRESS,
TOTAL_STRESS , VOLAT , MKTVAL , REGION,
MAX_LVL , PHC_SEQNUM , CNT_GOVT_DELTA , CNT_LIBOR_DELTA,
CNT_CREDIT_DELTA , CNT_MARKET_DELTA , CNT_GOVT_STRESS , CNT_LIBOR_STRESS,
CNT_CREDIT_STRESS, CNT_MARKET_STRESS , CNT_TOTAL_STRESS , CNT_VOLAT,
CNT_MKTVAL
) INCLUDING NEW VALUES ;
PROMPT TO CREATE THE MATERIALIZED VIEW
PROMPT MV_AGG_SBOOK_VALUEDATE
CREATE MATERIALIZED VIEW MV_AGG_SBOOK_VALUEDATE
TABLESPACE FLASH_DATA_M
PARALLEL
PARTITION BY RANGE(VALUE_DATE)
(PARTITION P20040113 VALUES LESS THAN (TO_DATE(' 2004-01-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040227 VALUES LESS THAN (TO_DATE(' 2004-02-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040304 VALUES LESS THAN (TO_DATE(' 2004-03-05 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040305 VALUES LESS THAN (TO_DATE(' 2004-03-06 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040306 VALUES LESS THAN (TO_DATE(' 2004-03-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040307 VALUES LESS THAN (TO_DATE(' 2004-03-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040308 VALUES LESS THAN (TO_DATE(' 2004-03-09 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040309 VALUES LESS THAN (TO_DATE(' 2004-03-10 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040310 VALUES LESS THAN (TO_DATE(' 2004-03-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040311 VALUES LESS THAN (TO_DATE(' 2004-03-12 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040312 VALUES LESS THAN (TO_DATE(' 2004-03-13 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040313 VALUES LESS THAN (TO_DATE(' 2004-03-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040314 VALUES LESS THAN (TO_DATE(' 2004-03-15 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040315 VALUES LESS THAN (TO_DATE(' 2004-03-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040316 VALUES LESS THAN (TO_DATE(' 2004-03-17 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040317 VALUES LESS THAN (TO_DATE(' 2004-03-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040318 VALUES LESS THAN (TO_DATE(' 2004-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040319 VALUES LESS THAN (TO_DATE(' 2004-03-20 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040320 VALUES LESS THAN (TO_DATE(' 2004-03-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040321 VALUES LESS THAN (TO_DATE(' 2004-03-22 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040322 VALUES LESS THAN (TO_DATE(' 2004-03-23 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040323 VALUES LESS THAN (TO_DATE(' 2004-03-24 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040324 VALUES LESS THAN (TO_DATE(' 2004-03-25 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040325 VALUES LESS THAN (TO_DATE(' 2004-03-26 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040326 VALUES LESS THAN (TO_DATE(' 2004-03-27 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040327 VALUES LESS THAN (TO_DATE(' 2004-03-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040328 VALUES LESS THAN (TO_DATE(' 2004-03-29 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040329 VALUES LESS THAN (TO_DATE(' 2004-03-30 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040330 VALUES LESS THAN (TO_DATE(' 2004-03-31 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040331 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040401 VALUES LESS THAN (TO_DATE(' 2004-04-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040402 VALUES LESS THAN (TO_DATE(' 2004-04-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040403 VALUES LESS THAN (TO_DATE(' 2004-04-04 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040404 VALUES LESS THAN (TO_DATE(' 2004-04-05 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040405 VALUES LESS THAN (TO_DATE(' 2004-04-06 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040406 VALUES LESS THAN (TO_DATE(' 2004-04-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040407 VALUES LESS THAN (TO_DATE(' 2004-04-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040408 VALUES LESS THAN (TO_DATE(' 2004-04-09 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040409 VALUES LESS THAN (TO_DATE(' 2004-04-10 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040410 VALUES LESS THAN (TO_DATE(' 2004-04-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040411 VALUES LESS THAN (TO_DATE(' 2004-04-12 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040412 VALUES LESS THAN (TO_DATE(' 2004-04-13 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040413 VALUES LESS THAN (TO_DATE(' 2004-04-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040414 VALUES LESS THAN (TO_DATE(' 2004-04-15 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040415 VALUES LESS THAN (TO_DATE(' 2004-04-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040416 VALUES LESS THAN (TO_DATE(' 2004-04-17 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040417 VALUES LESS THAN (TO_DATE(' 2004-04-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040418 VALUES LESS THAN (TO_DATE(' 2004-04-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040419 VALUES LESS THAN (TO_DATE(' 2004-04-20 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040420 VALUES LESS THAN (TO_DATE(' 2004-04-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M,
PARTITION P20040421 VALUES LESS THAN (TO_DATE(' 2004-04-22 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE FLASH_DATA_M
BUILD IMMEDIATE
USING INDEX TABLESPACE FLASH_INDX_M
REFRESH FAST ON DEMAND
ENABLE QUERY REWRITE
AS
SELECT
VALUE_DATE,
NAME_4,
NAME_5,
NAME_6,
NAME_7,
BOOK,
SYS_BOOK,
FXRATE,
COUNT(*) CNT,
SUM(GOVT_DELTA) GOVT_DELTA,
SUM(LIBOR_DELTA) LIBOR_DELTA,
SUM(CREDIT_DELTA) CREDIT_DELTA,
SUM(MARKET_DELTA) MARKET_DELTA,
SUM(GOVT_STRESS) GOVT_STRESS,
SUM(LIBOR_STRESS) LIBOR_STRESS,
SUM(CREDIT_STRESS) CREDIT_STRESS,
SUM(MARKET_STRESS) MARKET_STRESS,
SUM(TOTAL_STRESS) TOTAL_STRESS,
SUM(MKTVAL) MKTVAL,
COUNT(GOVT_DELTA) CNT_GOVT_DELTA,
COUNT(LIBOR_DELTA) CNT_LIBOR_DELTA,
COUNT(CREDIT_DELTA) CNT_CREDIT_DELTA,
COUNT(MARKET_DELTA) CNT_MARKET_DELTA,
COUNT(GOVT_STRESS) CNT_GOVT_STRESS,
COUNT(LIBOR_STRESS) CNT_LIBOR_STRESS,
COUNT(CREDIT_STRESS) CNT_CREDIT_STRESS,
COUNT(MARKET_STRESS) CNT_MARKET_STRESS,
COUNT(TOTAL_STRESS) CNT_TOTAL_STRESS,
COUNT(MKTVAL) CNT_MKTVAL
FROM
MV_AGG_RISK_REPORT_CACHE_SBOOK
GROUP BY
VALUE_DATE,
NAME_4,
NAME_5,
NAME_6,
NAME_7,
BOOK,
SYS_BOOK,
FXRATE;"fast" is a bit of a misnomer-- it is really an incremental refresh. Every change to the base table is recorded and propagated to the materialized view. The problem is that if every row changes, Oracle has to process a whole lot of increments, one by one. If it does a complete refresh, on the other hand, it can do set-wise operations, which is what the Oracle database is designed to do most efficiently.
In your case, the choice is between applying 24,000 change records (12,000 DELETE's followed by 12,000 INSERT's) in order or reading the 12,000 new rows as a set. It will be much faster for Oracle to do the latter.
It may be possible to tune the incremental refresh, depending upon how the base table is deleted and refreshed, but it will never be as fast as a complete refresh (unless you stop reloading the base table).
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Materialized view - fast refresh logs
I understand that there will be a Change Data Capture(CDC) log maintained internally for materialized view fast refresh to happen.
My question is, will this log get purged once the changes are applied to corresponding materialized view or will it persist with further changes getting appended to it ?
What would be the size of change log for 150 million records covering 40 base tables ?MV log entries are deleted when all registered materialized views that depend on them have refreshed.
For example: Suppose you have a table T and materialized views A and B that are fast-refresh and depend on the MV log for T.
On Monday you refresh MV A. The log entries are nto purged because B has not yet incorporated them.
On Tuesday you refresh MV B. At this point the log entries are purged up to the time on Monday that A was refreshed, because all MVs have processed them.
On Wednesday you refresh MV A again. At this point the log entries are purged up to the time on Tuesday that A was refreshed. etc. -
Materialized View fast refresh problems
I have two databases (A and B).
In database A, user NICK has a table called COLOUR_MASTER.
Also in that database, NICK issues the command create materialized view log on colour_master with primary key including new values (and yes, there is a primary key defined for this table)
In database B, there is a database link called A_LINK, connect to nick identified by password using 'dbA';
Also in database B, user IAN creates a materialized view CM_MV refresh fast as select * from colour_master@A_LINK
That statement completes successfully, and there are several million rows in CM_MV when it's done.
Immediately, IAN issues this command:
begin
dbms_mview.refresh('CM_MV');
end;
...and after a slight pause, he gets the error
ORA-12008: error in materialized view refresh path
ORA-02068: following sever error from A_LINK
ORA-03113: end-of-file on communication channel
Yet a +'select count(*) from colour_master@A_LINK'+ submitted immediately manages to return the correct number of records in database A -so that 3113 is a bit misleading, I think, in that instance A did not crash, the database remains accessible at all times, there are no networking issues (database A and B are both located in the same server room, so this isn't like I'm trying to connect half way round the globe).
The only thing I can think of is that there's a permissions problem causing this error. That because the MV creation is done via a link, there's no problem in IAN seeing the appropriate objects, but that once refreshes come into play, maybe there is.
Can anyone shed any light on why I can't do the fast refresh of the view I can happily create, please?I'm surprised that no-one has asked you to do the obvious: try doing a select * from colour_master@A_LINK, without that being wrapped up in a create materialized view statment. Just do a plain select * from...
My bet is that you'll get an ORA_22992 cannot use LOB locators selected from remote tables error. And if you can't do a simple select * from a remote table, I suspect that you can reasonably expect fireworks when you try to create or refresh a materialized view on such a thing!
Here's a quick test:
In Database 1:
=========
SQL> create table A (col1 varchar2(2), col2 clob);
Table created.
SQL> alter table A add constraint A1 primary key (col1);
Table altered.
SQL> insert into A values ('AA','This is an entry into a clob column');
1 row created.
SQL> commit;
Commit complete.
SQL> create materialized view log on A with primary key including new values;
Materialized view log created.In Database 2
=========
SQL> connect ims_global/v0yager1@ussd
Connected.
SQL> create materialized view B refresh fast as
2 select * from A@remotedb_link;
Materialized view created.
SQL> exec dbms_mview.refresh('B');
BEGIN dbms_mview.refresh('B'); END;
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-02068: following severe error from REMOTEDB_LINK
ORA-03113: end-of-file on communication channel
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2251
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2457
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2426
ORA-06512: at line 1
SQL> drop materialized view B;
Materialized view dropped.
SQL> create materialized view B refresh fast as
2 select col1 from A@ims_link;
Materialized view created.
SQL> exec dbms_mview.refresh('B');
PL/SQL procedure successfully completed.Which seems to replicate your problem rather well, I think.
I don't know if there are any workarounds for this. I mean, obviously you can miss out the CLOB column in your 'create MV' statement as I just did, but I don't know whether you are even allowed or supposed to be able to create an MV on lob columns and that patch such-and-such will let you do it. Maybe someone else can provide that information.
But at least you won't have to play Russian roulette with your init.ora parameters! -
Dear Dev/DBAs,
I have the following scenario:
SQL> CREATE TABLE T1 (ID NUMBER(3),NAME VARCHAR2(10));
SQL> CREATE TABLE T2 (ID NUMBER(3),NAME VARCHAR2(10));
The T1 contains records having the ID num from 10 to 80 and the T2 having the ID from 90 to 170
SQL> SELECT * FROM T1 JOIN ALL SELECT * FROM T2
It give all records in the 2 tables.
I'm planning to create a materialized view (like CREATE MATERIALIZED VIEW V_TAB REFRESH ON COMMIT AS SELECT * FROM T1 JOIN ALL SELECT * FROM T2) and it seems i can't do with the error ORA-12054, further the oracle documentation says that materialized view can only be used with a simple join.
Do you have another solution??
Note that the materialized views can be used to improve queries.
Thank you in advanceStraight from the link I posted:
*Restrictions on Fast Refresh on Materialized Views with UNION ALL*Materialized views with the UNION ALL set operator support the REFRESH FAST option if the following conditions are satisfied:
* The defining query must have the UNION ALL operator at the top level.
The UNION ALL operator cannot be embedded inside a subquery, with one exception: The UNION ALL can be in a subquery in the FROM clause provided the defining query is of the form SELECT * FROM (view or subquery with UNION ALL) as in the following example:
CREATE VIEW view_with_unionall AS
(SELECT c.rowid crid, c.cust_id, 2 umarker
FROM customers c WHERE c.cust_last_name = 'Smith'
UNION ALL
SELECT c.rowid crid, c.cust_id, 3 umarker
FROM customers c WHERE c.cust_last_name = 'Jones');
CREATE MATERIALIZED VIEW unionall_inside_view_mv
REFRESH FAST ON DEMAND AS
SELECT * FROM view_with_unionall;
Note that the view view_with_unionall satisfies the requirements for fast refresh.
* Each query block in the UNION ALL query must satisfy the requirements of a fast refreshable materialized view with aggregates or a fast refreshable materialized view with joins.
The appropriate materialized view logs must be created on the tables as required for the corresponding type of fast refreshable materialized view.
Note that the Oracle Database also allows the special case of a single table materialized view with joins only provided the ROWID column has been included in the SELECT list and in the materialized view log. This is shown in the defining query of the view view_with_unionall.
* The SELECT list of each query must include a maintenance column, called a UNION ALL marker. The UNION ALL column must have a distinct constant numeric or string value in each UNION ALL branch. Further, the marker column must appear in the same ordinal position in the SELECT list of each query block.
* Some features such as outer joins, insert-only aggregate materialized view queries and remote tables are not supported for materialized views with UNION ALL.
* Partiton Change Tracking (PCT)-based refresh is not supported for UNION ALL materialized views.
* The compatibility initialization parameter must be set to 9.2.0 or higher to create a fast refreshable materialized view with UNION ALL. -
Materialized View with Joins and Possibilities of Partitioning
Hi,
We have a materialized view which has a data to query around 12 gb. The query goes some thing like
this.
Select a.c1,a.c2,b.c1,b.c2,c.c1,c.c2
from a,b,c
where a.c1=b.c1
--and the where condition goes on...
--i.e Basically joining 3 different tables with complex join conditions but without any group functions and subqueries.
Now i have few questions here.
Firstly as the Mview is created with joins we will have to create separate logs for each tables and we have did the same. The logs are created with rowid and sequence for better performance during refresh.
Question No 1
Is this is a best approach for materializing a query with complex join conditions. Or Is it better to make 3 different materialized views for each 3 tables and join those 3 MViews and write a query for my report. I ask this question just to make sure the refresh time is brought down by this method. But as such as we have created 3 different logs for 3 tables the refresh must be happening separately.
Question No 2
Data is likely to grow faster and faster on this. So we have a idea of making this a partitioned Mview. Can the Pro's advice me on this and suggest me the right practice for the same and help me to correct links from where i can pick a example and continue from there.
Question No 3
How to find whether the materialized view has refreshed on a fast mode or complete mode after the last refresh.
Apart from querying and checking the rowid which i feel is quiet cumbersome for a mview with a data volume like what we have. By default when i see the info in TOAD for this Mview it shows Refresh Mode as "Force". But how to ascertain this.
Thanks in anticipation for a good round of discussionHi,
We have a materialized view which has a data to query around 12 gb. The query goes some thing like
this.
Select a.c1,a.c2,b.c1,b.c2,c.c1,c.c2
from a,b,c
where a.c1=b.c1
--and the where condition goes on...
--i.e Basically joining 3 different tables with complex join conditions but without any group functions and subqueries.
Now i have few questions here.
Firstly as the Mview is created with joins we will have to create separate logs for each tables and we have did the same. The logs are created with rowid and sequence for better performance during refresh.
Question No 1
Is this is a best approach for materializing a query with complex join conditions. Or Is it better to make 3 different materialized views for each 3 tables and join those 3 MViews and write a query for my report. I ask this question just to make sure the refresh time is brought down by this method. But as such as we have created 3 different logs for 3 tables the refresh must be happening separately.
Question No 2
Data is likely to grow faster and faster on this. So we have a idea of making this a partitioned Mview. Can the Pro's advice me on this and suggest me the right practice for the same and help me to correct links from where i can pick a example and continue from there.
Question No 3
How to find whether the materialized view has refreshed on a fast mode or complete mode after the last refresh.
Apart from querying and checking the rowid which i feel is quiet cumbersome for a mview with a data volume like what we have. By default when i see the info in TOAD for this Mview it shows Refresh Mode as "Force". But how to ascertain this.
Thanks in anticipation for a good round of discussion -
In 10g release 2,I tried to create following materialized view with join:
test_link is a normal table
test_geom is a table contains a column in SDO_GEOMETRY
CREATE MATERIALIZED VIEW LOG ON test_link with rowid
CREATE MATERIALIZED VIEW LOG ON test_geom with rowid,primary key
CREATE MATERIALIZED VIEW MV_LINK USING INDEX REFRESH FAST ON DEMAND AS
SELECT li.rowid link_rowid,geom.rowid geom_rowid,li.link_id,geom.link
FROM test_link li, test_geom geom
WHERE li.link_id=geom.link_id
But I always got an error like:
ORA-12015: cannot create a fast refresh materialized view from a complex query
If I change the geometry table to another table, everything works fine.
Anyone have ideas?Unfortunately, creating a fast refreshable materialized view on a join with one of the select columns being a user defined type (sdo_geometry is a user defined type) is not allowed. See 5303489 in the metalink bug database.
You could do like the workaround in the article suggests and create two materialized views and then create a regular view on top.
In our scenario, our materialized view also contains unions, so we would really like to have one physical object at the end of the day. One approach that we are currently investigating is to create the materialized view (MV1) without the geometry column, which makes it fast refreshable, and also create a materialized view (MV2) on the table containing the geometry column. MV2 is also fast refreshable. We then create a table (T3) that contains all of the columns from MV1, plus a geometry column. An insert, update, delete trigger on MV1 is created. The trigger is used to push all of the columns from MV1 to T3 and the geometry column from MV2 to T3. I have created the above in one of our test environments and haven't encountered any issues yet.
Let me know if you come up with a better approach.
Maybe you are looking for
-
Creation of ZRPA_MARM in Retail
Hello! I have created new info-object ZRPA_MARM in retail BW project. I want to know when ever we create a new Bespoke info-objects, WHY all the related tables are created in local instead of storing transport request where info-object is stored. for
-
Problems Implementing SnapShots Scenario for Stock Management
Hello All, I am trying to configure the Inventory Management with snapshots and I am using the snapshot scenario. According to the document I have created alternative ODS ODSSNAP and infocubes to accumulate 2LIS_03_BX, 2LIS_03_BF and 2LIS_03_UM. My p
-
Hi All, Is there any report to see the customer list based on account group. The report VCUST gives the entire list of customers. I want to see the list of customers based on accounts group. Regards Sankar.
-
Unable to reterview attributes using SPML
HI We have used SPML to reterive and update directory attributes to a web resource. But in production we cant reterive the directory attributes from CUR. THough I am able to update the attributes to CUR. All the workflows and form that require a rete
-
Oracle 9i DB + Jdeveloper + 9iAS JE / JRun / Tomcat
HI, i just to consider which application server suitable for our business. everybody can answer/explain me below question. 1) whatis difference between above mentioned app. server. what benefit if i choose 9ias je. 2) when i try to install sample cod