Materialized view definition in oracle 9i
How do we find the definiton (or the script) of a materialized view ? I am using oracle 9i and toad. The script tab of toad throws up the 'create table' script and not the original sql which defined the materialized view.
Please help.
You can use DBMS_METADATA :
SCOTT@orcl SQL> create materialized view mv_emp
2 refresh fast on demand with rowid
3* as select empno,ename,job,sal from emp
SCOTT@orcl SQL> /
Materialized view created.
SCOTT@orcl SQL> set long 100000
SCOTT@orcl SQL> select DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','MV_EMP','SCOTT') from dual
SCOTT@orcl SQL> /
DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','MV_EMP','SCOTT')
CREATE MATERIALIZED VIEW "SCOTT"."MV_EMP"
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOG
GING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
BUILD IMMEDIATE
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
REFRESH FAST ON DEMAND
WITH ROWID USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS select empno,ename,job,sal from emp
SCOTT@orcl SQL>
Similar Messages
-
Is materialized view available in Oracle SE ?
Hi all,
I have questions on materizlalized view :
1) Is materialized view available in Oracle Standard Edition ?
2) what is the meaning of "Materialized View Query Rewrite " ?
Thank you very much,
xtantoHi all,
I have questions on materizlalized view :
1) Is materialized view available in Oracle Standard
Edition ?http://www.oracle.com/technology/products/database/oracle11g/pdf/database-11g-product-family-technical-whitepaper.pdf
>
2) what is the meaning of "Materialized View Query
Rewrite " ?http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/qrbasic.htm#CIHDIEDI -
Replication of database views/materialized views from big oracle to mobile client
Hi all,
Has anyone done a replication of a view or a materialized view
from big oracle to oracle lite? I can get replication of a
database table happening(although I cant seem to find the table
when I log into the odb using msql) but it just doesn't seem to
work with views(hence the path I have taken which is to use
materialized views). Anyone? CheersHello,
Yesterday I met the same problem and very sad about this, however, my story is much more complicated (I think so).
I have 6 databases:
2 - 11g
2 - 10g
2 - 9i
Every database of each release has different characterset(UTF8 and AL16UTF16).
I am trying to create Materialized view with FAST REFRESH on Oracle 11g, when master tables are located on 10g database and 9i database.
Materialized view, which points to 9i database, was successfully created.
Materialized view, which points to 10g database, gets ORA-12028
Like you, I tried many notes from METALINK and thought at the begining that the problem is my characterset. But, when the materialized views were successfully built on Oracle 9i database, I understood that the problem is something else.
Did you find the actual reason why this issue does not work??
Thanks,
Alex -
Takes along time to view a materialized view definition
Hi,
Using owb 11.2.0.3 and takes a long time to see any materialized view definition which is based on a particular table (talking a few minutes compared to over a minute compared to seconds
to see other mview definitions.
platform aix.
8 million rows in base table.
Thoughts as to why this would be case?
Thanksuser5716448 wrote:
Hi,
Using owb 11.2.0.3 and takes a long time to see any materialized view definition which is based on a particular table (talking a few minutes compared to over a minute compared to seconds
to see other mview definitions.
platform aix.
8 million rows in base table.
Thoughts as to why this would be case?
Thanks
post actual EXPLAIN PLAN -
Can we use PIVOT in Materialized View Definition ?
Thanks
Dheeraj782331 wrote:
Can we use PIVOT in Materialized View Definition ?
Thanks
DheerajWhy not try it out and see?
It should likely take you 1 minute to put together a simple test case. -
Fast Refresh Nested Materialized View problem in ORACLE 9i 9.2.0.7
Hello
My problem is in creating fast refresh nested materialized view in oracle 9i
In below is an example of my problem
( I need to say when I run this example in Oracle 11g all things is OK )
create table ali.alitest1(id number primary key,n1 number,n2 number);
create table ali.alitest2(id number primary key,n3 number);
CREATE MATERIALIZED VIEW LOG ON ali.alitest1 WITH ROWID,PRIMARY KEY ,SEQUENCE
(n1,n2)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON ali.alitest2 WITH ROWID,PRIMARY KEY ,SEQUENCE
(n3)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW ali.alitest1_mv
REFRESH WITH PRIMARY KEY FAST
AS
select id,n1 from ali.alitest1;
CREATE MATERIALIZED VIEW LOG ON ali.alitest1_mv WITH ROWID,PRIMARY KEY ,SEQUENCE
(n1)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW ali.alitest2_mv
REFRESH WITH PRIMARY KEY FAST
AS
select t1.id,t1.n1,t2.n3,t1.rowid "t1_rowid",t2.rowid "t2_rowid" from ali.alitest1_mv t1,ali.alitest2 t2 where t1.id=t2.id;
SQL Error: ORA-12053: this is not a valid nested materialized view
12053. 00000 - "this is not a valid nested materialized view"
*Cause: The list of objects in the FROM clause of the definition of this
materialized view had some dependencies upon each other.
*Action: Refer to the documentation to see which types of nesting are valid.
do you know what is problem ?
thanksTake look for this link :
http://rwijk.blogspot.com/2009/08/fast-refreshable-materialized-view.html -
Materialized view definition from export
Hi,
Long time Oracle developer, first time poking with imp - I'm trying to find the definition on a materialized view from the dmp file, using windows.
I've used:
imp userid=dev/pwd file=C:\OraExports\DEV.dmp show=Y fromuser=devmgr touser=devmgr 2> c:\scott_all.txt
but can't locate the object I'm looking for - only the synonym of the same name.
Are snapshots included in a typical export? Any other suggestions for locating the SQL defn?
Cheers,
ScottHi,
What is the DB Version you are using. If its 9i there is some restriction with Export/Import. remove the cluse fromuser/touser and then Try.
Materialized View Concepts and Architecture
Are snapshots included in a typical export? Any other suggestions for locating the SQL defn?
You can user the dbms_metadata.get_ddl for the Sql definition, If your DB is in 10g and Above Version you can use the Datapump Export/Import.
HTH -
SQL command of Materialized View Relication in Oracle XE
Hi, all,
While waiting for the machine to be OK, I decide to post my understand of materialized view replication here and please point me anything incorrect.
I have two machines A and B, I want to make A as a master and B as replica, to replicate table test.
On A:
create materialized view log on test;
On B:
create database link dbl_a
connect to SYSTEM identified by password
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = a)(PORT = 1521))
(CONNECT_DATA =
(SID = XE)
create materialized view test_mview as select * from test@dbl_a;
At last, when I want to make a synchronization, I run
On B:
EXECUTE DBMS_MVIEW.REFRESH('test_mview');
Any point is appreciated.
Best wishes,
KemianYou can use DBMS_METADATA :
SCOTT@orcl SQL> create materialized view mv_emp
2 refresh fast on demand with rowid
3* as select empno,ename,job,sal from emp
SCOTT@orcl SQL> /
Materialized view created.
SCOTT@orcl SQL> set long 100000
SCOTT@orcl SQL> select DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','MV_EMP','SCOTT') from dual
SCOTT@orcl SQL> /
DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','MV_EMP','SCOTT')
CREATE MATERIALIZED VIEW "SCOTT"."MV_EMP"
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOG
GING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
BUILD IMMEDIATE
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
REFRESH FAST ON DEMAND
WITH ROWID USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS select empno,ename,job,sal from emp
SCOTT@orcl SQL> -
Can Oracle materialized view be used as crystal report datasource
Hi,
Can we use materialized view created in Orace 10g database as the data source of crystal reports.
I'm using Crystal reports Server 2008 V1 version. I'm unable to find the materialized view under my data connection. I can see only tables, static views and stored procedures.
Is there a way by which I can run my reports against a materialized view created in Oracle.
Thanks
Thomas ELHi Thomas,
Rather than doing all of this work around to access multiple databases/servers why not create a stored procedure to do all of this for you? Search the notes area for samples on how/what CR requires to use a SP in Oracle.
Advantages is this is done all server side and CR simply waits for the data to be returned. Even if you are using a BVM or connecting directly to the SP, both cases are server side. Database servers are much more efficient and optimized to run queries and filtering data. CR has to do the filtering on it's second pass and that causes performance delays.
Thank you
Don -
Materialized views on prebuilt tables - query rewrite
Hi Everyone,
I am currently counting on implementing the query rewrite functionality via materialized views to leverage existing aggregated tables.
Goal*: to use aggregate-awareness for our queries
How*: by creating views on existing aggregates loaded via ETL (+CREATE MATERIALIZED VIEW xxx on ON PREBUILT TABLE ENABLE QUERY REWRITE+)
Advantage*: leverage oracle functionalities + render logical model simpler (no aggregates)
Disadvantage*: existing ETL's need to be written as SQL in view creation statement --> aggregation rule exists twice (once on db, once in ETL)
Issue*: Certain ETL's are quite complex via lookups, functions, ... --> might create overy complex SQLs in view creation statements
My question: is there a way around the issue described? (I'm assuming the SQL in the view creation is necessary for oracle to know when an aggregate can be used)
Best practices & shared experiences are welcome as well of course
Kind regards,
Peterstreefpo wrote:
I'm still in the process of testing, but the drops should not be necessary.
Remember: The materialized view is nothing but a definition - the table itself continues to exist as before.
So as long as the definition doesn't change (added column, changed calculation, ...), the materialized view doesn't need to be re-created. (as the data is not maintained by Oracle)Thanks for reminding me but if you find a documented approach I will be waiting because this was the basis of my argument from the beginning.
SQL> select * from v$version ;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> desc employees
Name Null? Type
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
SQL> select count(*) from employees ;
COUNT(*)
107
SQL> create table mv_table nologging as select department_id, sum(salary) as totalsal from employees group by department_id ;
Table created.
SQL> desc mv_table
Name Null? Type
DEPARTMENT_ID NUMBER(4)
TOTALSAL NUMBER
SQL> select count(*) from mv_table ;
COUNT(*)
12
SQL> create materialized view mv_table on prebuilt table with reduced precision enable query rewrite as select department_id, sum(salary) as totalsal from employees group by department_id ;
Materialized view created.
SQL> select count(*) from mv_table ;
COUNT(*)
12
SQL> select object_name, object_type from user_objects where object_name = 'MV_TABLE' ;
OBJECT_NAME OBJECT_TYPE
MV_TABLE TABLE
MV_TABLE MATERIALIZED VIEW
SQL> insert into mv_table values (999, 100) ;
insert into mv_table values (999, 100)
ERROR at line 1:
ORA-01732: data manipulation operation not legal on this view
SQL> update mv_table set totalsal = totalsal * 1.1 where department_id = 10 ;
update mv_table set totalsal = totalsal * 1.1 where department_id = 10
ERROR at line 1:
ORA-01732: data manipulation operation not legal on this view
SQL> delete from mv_table where totalsal <= 10000 ;
delete from mv_table where totalsal <= 10000
ERROR at line 1:
ORA-01732: data manipulation operation not legal on this view While investigating for this thread I actually made my own question redundant as the answer became gradually clear:
When using complex ETL's, I just need to make sure the complexity is located in the ETL loading the detailed table, not the aggregate
I'll try to clarify through an example:
- A detailed Table DET_SALES exists with Sales per Day, Store & Product
- An aggregated table AGG_SALES_MM exists with Sales, SalesStore per Month, Store & Product
- An ETL exists to load AGG_SALES_MM where Sales = SUM(Sales) & SalesStore = (SUM(Sales) Across Store)
--> i.e. the SalesStore measure will be derived out of a lookup
- A (Prebuilt) Materialized View will exist with the same column definitions as the ETL
--> to allow query-rewrite to know when to access the table
My concern was how to include the SalesStore in the materialized view definition (--> complex SQL!)
--> I should actually include SalesStore in the DET_SALES table, thus:
- including the 'Across Store' function in the detailed ETL
- rendering my Aggregation ETL into a simple GROUP BY
- rendering my materialized view definition into a simple GROUP BY as wellNot sure how close your example is to your actual problem. Also don't know if you are doing an incremental/complete data load and the data volume.
But the "SalesStore = (SUM(Sales) Across Store)" can be derived from the aggregated MV using analytical function. One can just create a normal view on top of MV for querying. It is hard to believe that aggregating in detail table during ETL load is the best approach but what do I know? -
ORA-12052 when create materialized view
I following the sample in Oracle document to create materialized viewCREATE MATERIALIZED VIEW LOG ON sales
WITH ROWID, SEQUENCE(amount_sold, time_id, prod_id) INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON times
WITH ROWID, SEQUENCE (time_id, calendar_year) INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON products
WITH ROWID, SEQUENCE (prod_id,prod_name) INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW sales_mv
BUILD IMMEDIATE REFRESH FAST ON COMMIT
AS SELECT t.calendar_year, p.prod_id, p.prod_name,
SUM(s.amount_sold) AS sum_sales
FROM times t, products p, sales s
WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id
GROUP BY t.calendar_year, p.prod_id, p.prod_name; This works. BUt I actually does not want do aggregation. Thus I changed the MV creation statement toCREATE MATERIALIZED VIEW sales_mv
BUILD IMMEDIATE REFRESH FAST ON COMMIT
AS SELECT t.calendar_year, p.prod_id, p.prod_name,s.amount_sold
FROM times t, products p, sales s
WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id;I got errorSQL Error: ORA-12052: cannot fast refresh materialized view GLU.SALES_MV
*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.Please help or point me to the relevant document.
Thanksdamorgan, Thank you for you reply.
the inner table of an outer join did not have UNIQUE constraints on join columns.
I am not sure how much clearer and explanation can be written.If you look at the query, you will find that there is no outer join in the query.
sales table does not have unique constraints on prod_id and time_id. If this is the cause of the problem, I cannot change the data but is there a work around. That is way I ask for specific doc. In 11g documents, I only find some info on CREATE MV. That is mainly on syntax but not on requirement. -
Materialized View Fast Refresh been ignored For Complete refresh.
Hi,
I have a script that create a materialised view with a refresh method of 'FAST'.
When I refresh the view on one machine it refreshes using the 'FAST' method (i.e. LAST_REFRESH_TYPE = FAST) in 22 seconds, however, when I run the same script on a different machine the database chooses a 'COMPLETE' refresh method, despite me stating explicitly for it to use the FAST method. The complete refresh completes in about four hours.
Does anyone know the logic that Oracle uses in determining the type of refresh to use?
Thanks.Assuming that the Materialized View definition is the same (and doesn't conflict with any FAST REFRESH requirements for that specific Oracle Version), check to see if the source table(s) has/have Materialized View Logs defined on them. MV Logs with PK/Rowid would be required.
Hemant K Chitale -
Materialized view issue ORA-12052
Hi All,
I'm currently trying to create a MV using Fast refresh method.
and I'm getting the following error:
ORA-12052:
cannot fast refresh materialized view string.string
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.
I'm trying to create the Unique constraints required. Could anybody help me with this?. Which are the "inner tables of an outer join"?
I have also created the MVs logs with rowid, but also nothing happend.
I' ve created a Unique constraint that includes all the fields of the ourter joins. Nothing happend either.
Thi is the MV script:
'CREATE MATERIALIZED VIEW MVIEW1
USING INDEX
REFRESH ON DEMAND FAST
WITH rowid
DISABLE QUERY REWRITE AS
SELECT fp.FINAL_AMOUNTFIXED,
fp.FINAL_FPRATE,
fp.updated_rate,
fp.gsd_rate,
fp.nongsd_rate,
fp.AMT_CD,
fp.AMT_CD_ADJ1,
fp.AMT_CD_ADJ2,
fp.AMT_LC,
fp.AMT_LC_ADJ1,
fp.AMT_LC_ADJ2,
fp.ASSIGNMENT_STATUS,
fp.CURRENCY,
fp.DOLLARS,
fp.FORECAST_REVENUE_STATUS,
fp.GUID,
NVL(fp.HOURS,0) HOURS,
fp.ID,
fp.JOB_LEVEL,
fp.PJR_AMT_CD,
fp.PJR_HOURS_VALUE,
fp.PJR_LC,
fp.PJR_RATE,
fp.PJR_RATE_VALUE,
fp.PROJECT_COST_CENTER,
fp.PROJECT_COST_CENTERTXT,
NVL(cust.project_manager,fp.project_manager) project_manager,
NVL(cust.project_name,fp.project_name) project_name,
fp.PROJECT_NUMBER,
fp.PROJECT_ORGANIZATION,
NVL(cust.project_status,fp.project_status) project_status,
NVL(cust.project_type,fp.project_type) project_type,
NVL(fp.RATE,0) Rate,
fp.RATE_ADJ1,
fp.RATE_ADJ2,
fp.RATE_LEVEL,
fp.REPORT_DATE_ID,
fp.REPORT_DESCRIPTION,
fp.RESOURCE_COST_CENTER,
fp.RESOURCE_COST_CENTERTXT,
fp.RESOURCE_COUNTRY,
fp.RESOURCE_NAME,
fp.RESOURCE_ORGANIZATION,
fp.RESOURCE_TYPE,
fp.REVENUECOST_TYPE,
fp.ROLE_END_DATE,
fp.ROLE_NAME,
fp.ROLE_START_DATE,
fp.TAB,
fp.TASK_NUMBER,
fp.TPRATE_TP,
fp.WAR,
fp.WE_DATE_ID,
fp.WEEK,
fp.WORK_TYPE,
fp.PJR_FF_DIFF_MONTH,
fp.PJR_FF_DIFF_QTR,
NVL(fp.PJR_WOW,0) WOW,
fp.PJR_WOW_HRS,
fp.REMOVED_BY_ADJUSTMENT,
fp.PICK_FOR_WRITEBACK,
fp.DRAFT_REV_NUM,
fp.DRAFT_INV_NUM,
NVL(pca.country,fp.PROJECT_COUNTRY) Country,
NVL(cust.customer_id,NVL(fp.CUSTOMER_NUMBER,'TBD')) Customer_ID,
NVL(cust.CUSTOMER_NAME,NVL(fp.CUSTOMER_NAME,'TBD')) Customer_Name ,
fp.ITEM_DATE,
fp.REVENUE_CC,
fp.EXPLANATION,
fp.REPORT,
fp.REPORT_ADJUSTMENT,
fp.REPORT_ADJ1,
fp.REPORT_ADJ2,
fp.JE_DESCRIPTION,
pca.REGION_HQ_TIERLAST_CODE,
pca.MANAGER_FIELD_TIERLAST_CODE,
pca.SPECIALTY_HQ_TIERLAST_CODE,
pca.SECTOR_HQ_TIERLAST_CODE,
rca.REGION_HQ_TIERLAST_CODE,
rca.MANAGER_FIELD_TIERLAST_CODE,
rca.SPECIALTY_HQ_TIERLAST_CODE,
rca.SECTOR_HQ_TIERLAST_CODE,
pca.VERTICALS_SUB_LOB,
pca.MISC_GROUP ,
rca.VERTICALS_SUB_LOB,
rca.MISC_GROUP ,
fp.gl_date,
fp.pjr_wow_rate ,
fp.created_by,
fp.created_on,
NVL(fp.TOTAL_FUNDING,0) TOTAL_FUNDING,
NVL(fp.INCEPTION_TO_BURN,0) INCEPTION_TO_BURN,
NVL(fp.AVAILABLE_FUNDING,0) AVAILABLE_FUNDING,
NVL(fp.FORECAST_AMT,0) FORECAST_AMT,
cust.pop_date,
fp.COMMENTS_WOW_PROJ,
fp.COMMENTS_PAPER_CONFIRM,
rep.LOOKUP_CODE,
rep.NAC_SORTING1,
fp.ACTION_TO_CLOSE,
NVL(fp.NEGATIVE_BACKLOG,0) NEGATIVE_BACKLOG,
fp.SALES_REP,
fp.FORECAST_DATE,
pca.NAC_RES_TYPE_3,
rca.NAC_RES_TYPE_3
FROM FACT_PJR fp,
COSTCENTER_ATTRIBUTES pca ,
COSTCENTER_ATTRIBUTES rca,
wb_customer_lookups cust,
XXAPX_LOOKUPS rep
WHERE fp.revenue_cc = pca.LEAF_CC(+)
AND fp.RESOURCE_COST_CENTER = rca.LEAF_CC(+)
AND fp.project_number = cust.project_number(+)
AND fp.REPORT_ADJ2 = rep.VALUE(+)
AND rep.LOOKUP_TYPE = 'NAC_WB_PHASE2';'
Edited by: 859267 on May 3, 2012 11:51 AMPlease edit your post and surround the code with code tags. See 'Are there any useful formatting options not shown on the sidebar?' in the FAQ.
Also provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION). -
Materialized view log update question
Hi, I am running into a question regarding mview - not sure if it should behave that way or I didn't use it right.
I have two base tables, sales and customers (drived from nested materialized view example in oracle doc):
CREATE TABLE sales
cust_ID VARCHAR2(32 BYTE) NOT NULL,
amount_sold NUMBER,
TEMP VARCHAR2(100 BYTE),
CONSTRAINT sales_pk PRIMARY KEY (cust_id)
CREATE TABLE customers
cust_ID VARCHAR2(32 BYTE) NOT NULL,
CUST_LAST_NAME VARCHAR2(100 BYTE),
TEMP VARCHAR2(100 BYTE),
CONSTRAINT cust_pk PRIMARY KEY (cust_id)
CREATE MATERIALIZED VIEW LOG ON sales
WITH ROWID (cust_id, amount_sold);
CREATE MATERIALIZED VIEW LOG ON customers
WITH ROWID (cust_id, cust_last_name);
Then I create a fast refresh materialized view based on them:
CREATE MATERIALIZED VIEW join_sales_cust
REFRESH FAST ON DEMAND AS
SELECT c.cust_id, c.cust_last_name, s.amount_sold, s.rowid srid, c.rowid crid
FROM sales s, customers c
WHERE s.cust_id = c.cust_id;
Since this materialized view only invole cust_id and amount_sold from sales and cust_id and last_name from customers table, I do not want to trigger materialized view log entry if the TEMP column value gets updated. So follow update shouldn't trigger mlog:
update sales set TEMP='TEMP2' where cust_id=1
but this update should:
update sales set amount_sold=3 where cust_id=1
What I am seeing happenning is any update on the base table will triger mlog entried regardless whether the column is involed in the materialized view or not.
Can someone please confirm if this is the correct behavior and whether there is a way to accomplish what I wanted to do?
Thank you!
Edited by: user3933488 on Jan 8, 2010 12:53 PMYou created the materialized view logs with some columns, which is not necessary when creating a join MV on top of them. You can happily skip those in your MV log definition. And then it becomes clear that those columns are not involved in the decision whether a MV log needs to be updated or not. Everything that happens to the base table gets recorded. The "WITH ROWID" and "INCLUDING NEW VALUES" and the column list only specify WHAT should be recorded when something changed.
Regards,
Rob. -
Refresh of a materialized view
Hi All!
I have a materialized view defined like:
CREATE MATERIALIZED VIEW v_ship_info_new
PCTFREE 5 PCTUSED 60
TABLESPACE DATA_BIG
STORAGE
INITIAL 32768K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
USING INDEX STORAGE (INITIAL 2M NEXT 500K)
REFRESH START WITH ROUND(SYSDATE + 1) + 08/24
NEXT ROUND(SYSDATE + 2) + 08/24
AS
SELECT .....
The view was created on Sep.-13-2005. I expected that the view will be refreshed today at 08:00 AM, but the last_ddl_time in user_objects is Sep.-18-2005 and the data in the view is also from Sep.-18-2005. There is no time filter in SELECT statement. The view should shows a result of left outer join of two tables.
Any idea?
Thanks,
AndrejAndrej,
You should consider the NEXT interval relative to the last materialized view refresh. Reading your materialized view definition it results that:
- the materialized view was refreshed for the first time on 14-sep at 8:00 am (START WITH ROUND(SYSDATE + 1) + 08/24)
- the materialized view is then refreshed on 16-sep at 8:00 am, 18-sep at 8:00 am (ROUND(SYSDATE + 2) + 08/24)
Considering you have specified the START WITH clause in your command, the NEXT date should be considered starting from the timestamp of the last refresh and not from the moment of the materialized view creation.
Regards,
Adi
Maybe you are looking for
-
Hi all, 1.How can u restrict the creation of PO for a deleted PR? I have made the two system messages 06 076 and 06 400 to 'E'. Still it is allowing me to create PO?......... 2.I created one PO with PR,I deleted the reference PR from PO,still PR s
-
I am doing some memory profiling for an application running inside OC4J standalone. When the application is redeployed to OC4J, OC4J does not release memory for servlets and all the instances that's defined as class variables, e.g. private static Obj
-
Runtime error R6034. What do I do next?
Re iTunes. I have found and restored the missing DLL but now get a runtime error message R6034. Can anyone tell what to do next? Thanks!
-
Xml query foramt..
hi all, i need help with the following query, select xmlelement("l", xmlattributes(lxxxx_code as "id", xxxx_FLAG AS "b" , dbms_lob.substr(text,4000,1) as "d")) from wrk_xxxx_xx_l; the out put of the query should look like <l id="en_US" b="0" d="BUSH,
-
What software do i need on ipad2 if adobe flash will not work
what software do i need on my ipad2 if adobe flash is not compatible???? A webpage i use needs adobe flash???