Doubt Regarding Materialized View
Hello,
I am working on Oracle 10g.
We have multiple materialized Views which we Refresh in every 15 mins. My question is that can we get data from these MV's for a particular date....??
When i am Executing a query ..which was mentioned in the earlier post...m getting a particular error.
My Query
select * from db_rational_status_reaffirm_mv as of timestamp sysdate-1
Error m Getting
ORA-01555: snapshot too old : rollback segment number 4 with name "_SYSSMU4$" too small
Any Solution ..?
Similar Messages
-
Hi all,
I want to create materialized view, which will refresh the materialized view whenever, there is COMMIT on base table. The following
statement is correct for this requirement.
CREATE MATERIALIZED VIEW my_MV
BUILD IMMEDIATE
REFRESH COMPLETE
ON COMMIT
AS SELECT * FROM EMP@REMOTEDB;
and my question here is , is START WITH and NEXT values are required to fullfill my requirement.
Thanks,
PalHi,
If U need view to referesh to when base table is committed, then no need of start with and next.
START WITH CLAUSE --- > Specify a datetime expression for the first automatic refresh time
NEXT Clause --->
Specify a datetime expression for calculating the interval between automatic refreshes.
Both the START WITH and NEXT values must evaluate to a time in the future. If you omit the START WITH value, then the database determines the first automatic refresh time by evaluating the NEXT expression with respect to the creation time of the materialized view. If you specify a START WITH value but omit the NEXT value, then the database refreshes the materialized view only once. If you omit both the START WITH and NEXT values, or if you omit the create_mv_refresh entirely, then the database does not automatically refresh the materialized view.
Regards,
Simma,,, -
Query Regarding Materialized View
Hi,
I have materialized view mv_test which is derived from a base table test. My question is if I modify any of the column width of table test,do it effect on materialized view refresh?If so what are the procedures I need to follow if I want to modify the base table column size?
Thanks
Henauser11253970 wrote:
Hi,
I have materialized view mv_test which is derived from a base table test. My question is if I modify any of the column width of table test,do it effect on materialized view refresh?Yes. (Materialized) View is nothing but a select statement that will get executed on the base table when the view is accessed. So, you don't have to do anything special on the view when you change the datatype of the base table.
If so what are the procedures I need to follow if I want to modify the base table column size?You don't have to follow any procedure as such. Just make sure your data in the base table does not get affected by the change ;-)
-Arun
>
>
Thanks
Hena -
Query Regarding Materialized view invalid
Hi,
What is the reason for the Materialized view invalid.Question is vague. Can you be more specific?
-
Problem regarding Materialized View
Hi,
I have a master table "nms_num_schm" on SID-SLBANCS and its corresponding materialized view "mlog$_nms_num_schm". The MV is supposed to move data from this master table to a table "nms_num_schm_mv" on SID-ORCL.
The MV is set to select data after every 5 mins and the db link is also set. also the grants have also been provided.
I inserted the data in master table and data populated in the mlog table.But the problem is that its staying in mlog table and not moved to the "_mv" table even after 1 hr.Even though snaptime is populated with a time of refresh,the refresh didnt happen.
So 3 things here -
1) Why did the refresh didnt happen
2) If the refresh didnt happen because of any issue/error, where can I check what was the issue.
3) To make things worse, there are 17 more tables such similar setup. Some data refresh works sometimes, sometimes not.
Please provide your valuable comments to resolve the same.
Here's a snapshot of the mlog table -
insert into MLOG$_NMS_NUM_SCHM (NMS_SEC_ID, NMS_NMBRNG_SCHM, SNAPTIME$$, DMLTYPE$$, OLD_NEW$$, CHANGE_VECTOR$$)
values ('ZA00ISCDWD', 1, to_date('05-11-2008 11:17:07', 'dd-mm-yyyy hh24:mi:ss'), 'I', 'N', 'FEFF');Hi,
I have a master table "nms_num_schm" on SID-SLBANCS and its corresponding materialized view "mlog$_nms_num_schm". The MV is supposed to move data from this master table to a table "nms_num_schm_mv" on SID-ORCL.
The MV is set to select data after every 5 mins and the db link is also set. also the grants have also been provided.
I inserted the data in master table and data populated in the mlog table.But the problem is that its staying in mlog table and not moved to the "_mv" table even after 1 hr.Even though snaptime is populated with a time of refresh,the refresh didnt happen.
So 3 things here -
1) Why did the refresh didnt happen
2) If the refresh didnt happen because of any issue/error, where can I check what was the issue.
3) To make things worse, there are 17 more tables such similar setup. Some data refresh works sometimes, sometimes not.
Please provide your valuable comments to resolve the same.
Here's a snapshot of the mlog table -
insert into MLOG$_NMS_NUM_SCHM (NMS_SEC_ID, NMS_NMBRNG_SCHM, SNAPTIME$$, DMLTYPE$$, OLD_NEW$$, CHANGE_VECTOR$$)
values ('ZA00ISCDWD', 1, to_date('05-11-2008 11:17:07', 'dd-mm-yyyy hh24:mi:ss'), 'I', 'N', 'FEFF'); -
Help regarding Materialized view ( subquery expression not allowed here )
Hi all,
while creating materialized view i got following error
ORA- 22818
subquery expression not allowed here
following is my query
CREATE MATERIALIZED VIEW MV_NAV_REC
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND
as
select folio_no FOLIONO,CHKDIGIT as Check_Digit,sch_code SCHEMECODE, sysdate as FOLIODATE ,
(select case when count(distinct SUBBROKERCODE) =1 then to_char(max(SUBBROKERCODE)) else 'Multiple Broker' end from transaction_st
where folio_no = tst.folio_no
group by folio_no) ARN_Number ,
(select sum(case when tran_type in ('PURCHASE','SWITCH IN') then UNITS else 0 - UNITS end ) from transaction_st
where folio_no = tst.folio_no AND SCH_CODE = tst.sch_code
group by folio_no,sch_code) NUM_UNITS_NEW ,
--SUM (case when tran_type NOT in ('REDEMPTION','SWITCH OUT') THEN UNITS ELSE 0 - UNITS END ) AS Num_Units,
(select sum(case when tran_type in ('PURCHASE','SWITCH IN') then AMOUNT else 0 - AMOUNT end ) from transaction_st
where folio_no = tst.folio_no AND SCH_CODE = tst.sch_code
group by folio_no,SCH_CODE) as NUM_AMOUNT_NEW ,
--SUM (case when tran_type NOT in ('REDEMPTION','SWITCH OUT') THEN AMOUNT ELSE 0 -AMOUNT END ) AS Scheme_Amount,
sum( CASE WHEN upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN
units * (select nav_rs from nav_rec where nav_rec.sch_code = tst.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy'))
ELSE (0 - units) * (select nav_rs from nav_rec where nav_rec.sch_code = tst.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy')) END ) Scheme_Valuation ,
null as SCHEMEPHRASEID ,
null as "Prefered Mode of SOA",
( select sum( case when upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN AMOUNT ELSE 0 - AMOUNT END ) from transaction_st t where t.folio_no = tst.folio_no group by folio_no ) as Folio_Amount,
select sum(CASE when upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN
units * ( select nav_rs from nav_rec where nav_rec.sch_code = ts.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy'))
ELSE
(0 - units) * ( select nav_rs from nav_rec where nav_rec.sch_code = ts.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy')) END
) from transaction_st ts where ts.folio_no =tst.folio_no group by ts.folio_no
) as Folio_Valuation
from transaction_st tst
group by folio_no ,sch_code,CHKDIGIT
order by folio_no , SCH_CODE
please help meHi,
You cannot use scalar subqueries in a materialized view.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4110947624538#22981269011674
edit
From 10g doc:
ORA-22818: subquery expressions not allowed here
Cause: An attempt was made to use a subquery expression where these are not supported.
Action: Rewrite the statement without the subquery expression.
(http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/e19400.htm#sthref6020)
Edited by: hoek on Jun 10, 2009 7:56 AM -
Hi all,
I have two database .there is one table in first database.I want to synchronize this table with second database. for that i have created materialized view but when i am create that materialized view it gives following error
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
I m access table from first table to second database by database link.
How can resolve this error? Kindly give suggestion.
Thanks in advance.From the document.
Refresh Materialized Views
Oracle maintains the data in materialized views by refreshing them after changes are made to their master tables. The refresh method can be incremental (fast refresh) or complete. For materialized views that use the fast refresh method, a materialized view log or direct loader log keeps a record of changes to the master tables.
Materialized views can be refreshed either on demand or at regular time intervals. Alternatively, materialized views in the same database as their master tables can be refreshed whenever a transaction commits its changes to the master tables. -
Is materialized view logging feature requied?
Hi Professionals,
I have a doubt regarding Materialized View loggind feature,is it required? if required ,in what real time scenerios it will be used? For Example For a Materialized view of 1 million rows how much space it occupies? Can we determine size of logging information? Is it space consuming? If any error occurs in Materialized View can we trace the error using logging? Please clarify me.
Thanks
GaneshNo, it is not mandatory to have logging on your materialized view, unless you want to do incremental refreshes.
http://docs.oracle.com/cd/B19306_01/server.102/b14220/schema.htm#i18093 -
Hi All,
I have a question regarding materialized view.
I am adding new columns to the base table of a materialized view.As part of this I do recompiling dependent objects.Do I need to take any action on materialized views? I mean Validating or recreating?
Thanks
HenaAssuming that you're not expecting the new column to appear in the materialized view, you shouldn't need to do anything.
Justin -
UPDATING the query in materialized view
Hi,
i have a little doubt in Materialized view. i created a materialized view and log with the following query,
create table test_mv (a number ,b number )
alter table test_mv add constraint t_pk primary key ( a );
insert into test_mv values (1,2);
insert into test_mv values(2,2);
insert into test_mv values(3,2);
insert into test_mv values(4,2);
insert into test_mv values(5,2);
commit;
CREATE MATERIALIZED VIEW LOG ON test_mv
WITH SEQUENCE, ROWID
*(a,b)*
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW product_sales_mv
ENABLE QUERY REWRITE
AS SELECT b from test_mv;
Now i want to update the query in the MV as 'Select a from test_mv' . for that i tried with
*'ALTER MATERIALIZED VIEW product_sales_mv AS SELECT a from test_mv;'*
But it throwing error,
Error starting at line 5 in command:
alter MATERIALIZED VIEW product_sales_mv AS SELECT b from test_mv
Error report:
SQL Error: ORA-00933: SQL command not properly ended
+00933. 00000 - "SQL command not properly ended"+
*Cause:+
*Action:+
i guess i am doing wrong. kindly help me here. i want to update it without drop and recreate.
thanks,
Jeevanand.KeHi Jeeva,
No. you cannot add or drop columns to the materialized view using the ALTER Statement.
To Change the Structure of the view , drop and re-create the materialized view.
To Alter a materialized view log, You can use the ALTER MATERIALIZED VIEW LOG. By this,
You can add new columns to a materialized view log.
ALTER MATERIALIZED VIEW LOG ON sggi_mrps.emp ADD(deptno);Thanks,
Shankar
Edited by: Shankar Viji on Aug 24, 2012 2:11 AM -
Hi
I am ha query regarding Materialized View .
Materialized View Query :
select * from emp@db1 where salary in ('1000','3000');
Scenario :
In the DB2 (Target DB) :
create materialized view emp_mv
refresh force on demand
as
select * from emp@db1 where salary in ('1000','3000');
Replication works fine .
In DB1 (Source DB) :
Update emp set salary=2000 where salary=1000 and empno=123;
Now in the DB2 (where my MV is located) , i want the existing record (salary=1000) to be still there and the new record (salary=2000) should not be present for empno=123
In DB1 (Source DB) :
Update emp set salary=3000 where salary=2000 and empno=123;
Now in the DB2 (where my MV is located) , i want the previous record (salary=1000) to be still there and the new record (salary=3000) should also be present for empno=123 (Now there should be tow records)
Is it possible ?
Any pointers is appreciated !
ThanksA Materialized View is designed (intended) to give you a copy of data as the data exists in the source. If that row (with the pre-delete image) does not exist in the source, it should not exist in the MV.
How would you distinguish between the two images of the row at the MV site ? Which one is the "older" one and which is the "newer" one ? You'd have to write custom methods (tags, timestamps etc) to differentiate between the two rows.
A Materialized View is a generic solution. You cannot customize.
You have to define your own custom table (with the additional tagging methods) and your own procedures to replicate the two images of the same row. That is one of the uses of triggers. Before the row is updated, copy the preupdate image of the row (with additional column(s) for tagging the change) out to another table.
The "custom" MV can then be defined as a UNION of the two tables, the "master" table and the "audit trail" table.
You'll have to consider how you will handle DELETEs as well.
Hemant K Chitale -
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 -
Regarding Refresh in Materialized View having Join
Hi,
I have created a Materialized View on Primary Key out of a join between a Dimension and Fact Table of a Datawarehouse. Each of these tables contains close to 70 million records.
I have also created the Materialized View Logs on these two tables 'ON ROWID'.
Also, there is no explicit 'ROW_ID' column present in both the tables. So, it is also not present in the SELECT Query.
I used a REFRESH FAST Option and tried refreshing the View manually using the DBMS_MVIEWS Procedure. It gave an error ORA-12052 of unique constraints and missing rowids.
Can't I use the REFRESH FAST Option if there are no ROWID columns in the Master Tables?
Could you please let me know the resolution for this problem?
Many Thanks, KetanPost your version information and the DDL for your MV.
No table has a ROWID column ... ROWID is a pseudocolumn. -
Hi experts pls help me with this materialized view refresh time!!!
Hi Expeerts ,
Please clarify my doubt about this materialized view code
[\n]
CREATE MATERIALIZED VIEW SCHEMANAME.products_mv
REFRESH WITH ROWID
AS SELECT * from VIEW_TABLE@DATAOPPB;
[n]
Here i am creating a materialized view named products_mv of the view_table present in the remote server.Can anyone tell me when will my table product_mv will get refreshed if i follow this code.As what i read from the books is that the refresh period is implicit and is carried out by the database implicitly.so can u tell me suppose i insert 2 new records into my view_table when will this record get updated into my product_mv table.
I cant use primary key approach so this is the approach i am following .Kindly help me in understanding when will refresh of records occur in the materialized view product_mv...Pls help
regards
debashisHi Justin ,
Yes, my database can reasonably schedule other jobs too .Its not an issue.
Actually what i meant "fine in all aspects" is that will the matrerialized view will get refreshed w.r.t the documetum_v table present in my remote server.This is all i need to refresh my materialized view .
I queries the DBA_JOBS table .I could see the following result i have pasted below:-
[\n]
NLS_ENV
MISC_ENV INSTANCE
dbms_refresh.refresh('"WORKFLOW"."PRODUCTS_MV2"');
JOB LOG_USER PRIV_USER
SCHEMA_USER LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE
NEXT_SEC TOTAL_TIME B
INTERVAL
FAILURES
WHAT
[n]
here WORKFLOW"."PRODUCTS_MV2 is the materialized view i have created.So can u tell me that whether we can predict our refresh part is functioning fine from this data.If so how?
Actually i am asking u in details as i dont have much exposure to materialized view .I am using it for the very first time.
Regds
debashis -
Updatable materialized view- error with CREATE_SNAPSHOT_REPGROUP
I'm trying to create an updatable materialized view from the replication administrators account (REPADMIN). I use the assistant and in the third step (after creating the replication group and the materialized view), when the materialized view is going to be added to the group, I got this error:
ERROR in line 1:
ORA-01403: No data found
ORA-06512: in "SYS.DBMS_REPCAT_SNA_UTL", line 5927
ORA-06512: in "SYS.DBMS_REPCAT_SNA", line 82
ORA-06512: in "SYS.DBMS_REPCAT", line 1332
ORA-06512: in "SYS.DBMS_REPCAT", line 1307
ORA-06512: in line 2
I have also tried to use the command file that the assistant generates (I add below), and the error is triggered within the CREATE_SNAPSHOT_REPOBJECT procedure.
Has anybody any idea to resolve the problem?
Thanks in advance
BEGIN
DBMS_REPCAT.CREATE_SNAPSHOT_REPGROUP(
gname => '"MYGROUP"',
master => 'DB.DOMAIN.COM',
propagation_mode => 'ASYNCHRONOUS');
END;
CREATE SNAPSHOT "MYUSER"."MYTABLE"
REFRESH COMPLETE WITH ROWID
FOR UPDATE
AS SELECT "COD", "NAME" FROM
"MYUSER"."MYTABLE"@DB.DOMAIN.COM c
BEGIN
DBMS_REFRESH.ADD(
name => '"MYUSER"."REF3"',
list => '"MYUSER"."MYTABLE"',
lax => TRUE);
END;
BEGIN
DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT(
gname => '"MYGROUP"',
sname => '"MYUSER"',
oname => '"MYTABLE"',
type => 'SNAPSHOT',
min_communication => FALSE);
END;Hello,
These days I have had some problems with my forum-account and I haven't been able to connect and reply.
Regarding to your doubt, the name of refresh group was correct, and as I see, the problem can't be related to the refresh group.
While the problem with my account was resolved, I created two new databases (*) and the problem within the materialized view process is disappeared. I suppose that my first original databases were degraded, but I don't know where.
(*) of course, I could do that because I use Oracle in an academy institution, not for production, thank God
Anyway, for now I will give up here. Thanks for your help.
Regards,
Maybe you are looking for
-
HELP. Upgraded to 10.6.8 and now pics messed up!!
Hi, was happy with my old imac (really old - 7 years, 75 lines of pixels-but trying to get more life out of it) but hubby insisted i need to upgrade to snow leopard. so now i am at 10.6.8 (2ghz intel, cor 2 duo, 1gb 667mhz, ddr2, sdram) my ip
-
1.Bridge is slow, it oftens displays a cache error problem on start up even when I have emptied cache. 2.Camera RAW will not display the correct tool eg Adjustment Brush [k] shows the loading circle unless click return. I often have many hundreds of
-
Wrong file format while generating a txt file
Hi, I am using a java application to generate a txt file. This txt file will later be used by a spider. The problem is when the file is generated it has UNIX format. It means the '\n' characters at the end of the line are not the same as in a DOS fil
-
I just recently installed iLife 06 on a friends laptop here at school. She is a heavy iPhoto user and her library is quite large. The install went through fine, and everything works, except for iPhoto. When I open iPhoto is says that the iPhoto libra
-
Safari keeps crashing after a few minutes of use
Safair keeps crashing after a few minutes of use. it's crashed 3 times as i type this in. Process: WebProcess [2689] Path: /System/Library/StagedFrameworks/Safari/WebKit2.framework/WebProcess.app/Conten ts/MacOS/WebProcess Identif