Materialized View & SYSDATE
I don't know if I'm on the right forum for this. I am trying to create a materialized view, that refreshes once a month, with data for the last 2 years.
In the where-clause of my select, I am using:
and months_between(sysdate,sr.creation_date) <= 24
I also tried:
and sr.creation_date >= sysdate - 730
My collegue tells me that you cannot use sysdate in the where-clause for a materialized view. How can I do this without using sysdate ?
The column creation_date is defined as a DATE field.
Thanks Justin. This is a datawarehouse ... sort of. We installed Oracle on a server that we use for management reports. From here we create a lot of materialized views, which get their data from various other Operational databases (using database links). The data for this MV also comes from one of our production databases.
Maybe it will be clearer if I post the whole create statement. Oh yes, I am already doing a full (complete) refresh of the MV. (I tried both of the last 2 lines in the where clause below).
create materialized view HZ_PERSON_PROFILES_V
REFRESH COMPLETE
NEXT TRUNC(SYSDATE, 'MM')
as
select distinct pat.*
from apps.hz_person_profiles_v@ebusprod pat,
apps.cs_incidents_v@ebusprod sr
where pat.party_number = sr.customer_number
and incident_type_id in (10095,10096,10097,10098)
and sr.creation_date >= sysdate - 730;
--and months_between(sysdate,sr.creation_date) <= 24;
The error I get on this, is:
and months_between(sysdate,sr.creation_date) <= 24
ERROR at line 10:
ORA-23420: interval must evaluate to a time in the future
Similar Messages
-
Materialized View to run only once in a year...
Hi everybody...
I want to create a materialized view which will run only once in a year and specifically some minutes after 00:00 a.m. on new year's day,
so i created the following:
CREATE MATERIALIZED VIEW <mv_name>
BUILD IMMEDIATE
REFRESH START WITH TO_DATE('01/01/2007 00:15:00','DD/MM/RRRR HH24:MI:SS')
NEXT SYSDATE+366
I have two notes:
1) how to declare the refresh to be done the first new year's day after the day it'll be created , i mean not static date (01/01/2007)
2)some years are leap and some are not , so in order to run every new year's day how should i transform the above..????
3)is there any view which displays the next run of a materialized view..???
the view DBA_MV_REFRESH_TIMES displays the last refresh of mv's...
I use Oracle 10.2.0.1 on XP ...
Thanks , a lot
Simon1).
use the expression that evaluates to next january first.
SQL> select sysdate, add_months(trunc(sysdate, 'yyyy'), 12) from dual ;
SYSDATE ADD_MONTHS(
19-JUN-2006 01-JAN-2007
1 row selected.
SQL>2). for this also use the same expression that will evaluate to the january first of the year after that. -
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 -
A bug when refreshing a materialized view?
I am getting "ORA-00603: ORACLE server session terminated by fatal error" upon refresh of a materialized view. I've put together a test case to demonstrate the problem. Is it a bug?
SQL*Plus: Release 10.1.0.3.0 - Production on Fri Jul 29 13:43:45 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
[email protected]> create table t (
2 id int primary key,
3 t_name varchar2(10),
4 t_date date
5 );
Table created.
[email protected]> create materialized view log on t
2 with rowid (t_name, id, t_date) including new values;
Materialized view log created.
[email protected]> create materialized view t_mv
2 build immediate
3 refresh fast
4 on commit
5 as
6 select t_name, max(id) id, max(t_date) t_date, count(*)
7 from t
8 GROUP BY t_name;
Materialized view created.
[email protected]> create materialized view log on t_mv
2 with rowid (id) including new values;
Materialized view log created.
[email protected]> create table v (
2 id int primary key,
3 t_id int references t(id) on delete cascade,
4 v_name varchar2(10)
5 );
Table created.
[email protected]> create materialized view log on v
2 with rowid (v_name, t_id) including new values;
Materialized view log created.
[email protected]> create materialized view v_mv
2 build immediate
3 refresh fast
4 on commit
5 as
6 select v.rowid rowid1, t_mv.rowid rowid2, v.v_name, v.t_id
7 from v, t_mv
8 where v.t_id = t_mv.id;
Materialized view created.
[email protected]> alter table v_mv
2 add constraint v_mv_uk1 unique
3 (
4 v_name
5 )
6 enable
7 ;
Table altered.
[email protected]> insert into t (id, t_name, t_date) values (1, 'A', sysdate);
1 row created.
[email protected]> insert into t (id, t_name, t_date) values (2, 'B', sysdate);
1 row created.
[email protected]> insert into t (id, t_name, t_date) values (3, 'A', sysdate);
1 row created.
[email protected]> insert into t (id, t_name, t_date) values (4, 'A', sysdate);
1 row created.
[email protected]> insert into t (id, t_name, t_date) values (5, 'B', sysdate);
1 row created.
[email protected]> insert into v (id, t_id, v_name) values (1, 1, 'V_A_1');
1 row created.
[email protected]> insert into v (id, t_id, v_name) values (2, 2, 'V_B_1');
1 row created.
[email protected]> insert into v (id, t_id, v_name) values (3, 3, 'V_A_2');
1 row created.
[email protected]> insert into v (id, t_id, v_name) values (4, 4, 'V_A_3');
1 row created.
[email protected]> insert into v (id, t_id, v_name) values (5, 5, 'V_B_2');
1 row created.
[email protected]> commit;
Commit complete.
[email protected]> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
1 row created.
[email protected]> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
1 row created.
[email protected]> commit;
commit
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-00001: unique constraint (FESA.V_MV_UK1) violated
[email protected]> -- ORA-12008 is fine here: that's what was expected
[email protected]> delete from t where id = 5;
1 row deleted.
[email protected]> commit;
ERROR:
ORA-03114: not connected to ORACLE
commit
ERROR at line 1:
ORA-00603: ORACLE server session terminated by fatal errorWhy ORA-00603?
Best regards,
MaciejIt may be a bug, or it may be a result of the dependencies between the materialized views. I don't have a 9.2.0.6 instance that I'm willing to trash to test this, but this is what I get on 9.2.0.1.
If it is a bug they at least changed the behaviour of the bug in 9.2.0.6.
I ran your script up to the first commit then did:
SQL> SELECT * FROM t;
ID T_NAME T_DATE
1 A 29-JUL-05
2 B 29-JUL-05
3 A 29-JUL-05
4 A 29-JUL-05
5 B 29-JUL-05
SQL> SELECT * FROM t_mv;
T_NAME ID T_DATE COUNT(*)
A 4 29-JUL-05 3
B 5 29-JUL-05 2
SQL> SELECT * FROM v;
ID T_ID V_NAME
1 1 V_A_1
2 2 V_B_1
3 3 V_A_2
4 4 V_A_3
5 5 V_B_2
SQL> SELECT * FROM v_mv;
no rows selectedHUH?? But:
SQL> SELECT v.rowid rowid1, t_mv.rowid rowid2, v.v_name, v.t_id
2 FROM v, t_mv
3 WHERE v.t_id = t_mv.id;
ROWID1 ROWID2 V_NAME T_ID
AAAH4QAAIAAAAl1AAD AAAH4MAAIAAAAlFAAA V_A_3 4
AAAH4QAAIAAAAl1AAE AAAH4MAAIAAAAlFAAB V_B_2 5So, I tried:
SQL> EXEC DBMS_MVIEW.REFRESH('V_MV');
PL/SQL procedure successfully completed.
SQL> SELECT * FROM v_mv;
no rows selectedNow, this is confusing, so:
SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
PL/SQL procedure successfully completed.
SQL> SELECT * FROM v_mv;
ROWID1 ROWID2 V_NAME T_ID
AAAH4dAAIAAAAl1AAD AAAH4ZAAIAAAAlFAAA V_A_3 4
AAAH4dAAIAAAAl1AAE AAAH4ZAAIAAAAlFAAB V_B_2 5So at least I've got something in the MV. Now, to continue your test:
SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
1 row created.
SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
1 row created.
SQL> COMMIT;
Commit complete.I also expected the error but no joy, and look at this:
SQL> SELECT * FROM v_mv;
ROWID1 ROWID2 V_NAME T_ID
AAAH4dAAIAAAAl1AAE AAAH4ZAAIAAAAlFAAB V_B_2 5Forcing the refresh on v_mv gets:
SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
BEGIN DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE'); END;
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-00001: unique constraint (OPS$ORACLE.V_MV_UK1) violatedVery strange! It gets better:
SQL> DELETE FROM t WHERE id = 5;
1 row deleted.
SQL> commit;
Commit complete.
SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
PL/SQL procedure successfully completed.
SQL> select * from v_mv;
ROWID1 ROWID2 V_NAME T_ID
AAAH4dAAIAAAAl1AAF AAAH4ZAAIAAAAlFAAA V_B_2 6 But:
SQL> SELECT * FROM t_mv;
T_NAME ID T_DATE COUNT(*)
A 6 29-JUL-05 4
B 5 29-JUL-05 2
SQL> SELECT * FROM t;
ID T_NAME T_DATE
1 A 29-JUL-05
2 B 29-JUL-05
3 A 29-JUL-05
4 A 29-JUL-05
6 A 29-JUL-05Obvioulsy, something is not fast refreshing. So lets force it:
SQL> EXEC DBMS_MVIEW.Refresh('T_MV', 'COMPLETE');
PL/SQL procedure successfully completed.
SQL> SELECT * FROM t_mv;
T_NAME ID T_DATE COUNT(*)
A 6 29-JUL-05 4
B 2 29-JUL-05 1
SQL> SELECT * FROM v_mv;
ROWID1 ROWID2 V_NAME T_ID
AAAH4dAAIAAAAl1AAB AAAH4qAAIAAAAlEAAB V_B_1 2
AAAH4dAAIAAAAl1AAF AAAH4qAAIAAAAlEAAA V_B_2 6Which looks right to me.
Then, I blew everything away and did it allagain up to an including the inserts into t, then I inserted into v and commited. Now, both MV's were correct, so I did:
SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
1 row created.
SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
1 row created.
SQL> commit;
Commit complete.
SQL> SELECT * FROM t_mv;
T_NAME ID T_DATE COUNT(*)
A 6 29-JUL-05 4
B 5 29-JUL-05 2Still strange, so blow it all away again insert into t commit, insert into v commit, then:
SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
1 row created.
SQL> commit;
commit
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-00001: unique constraint (OPS$ORACLE.V_MV_UK1) violatedAt least now it sees the error at commit time for v so lets try the delete:
SQL> delete from t where id = 5;
1 row deleted.
SQL> commit;
Commit complete.
SQL> SELECT * FROM t_mv;
T_NAME ID T_DATE COUNT(*)
A 6 29-JUL-05 4
B 5 29-JUL-05 2
SQL> SELECT * FROM t;
ID T_NAME T_DATE
1 A 29-JUL-05
2 B 29-JUL-05
3 A 29-JUL-05
4 A 29-JUL-05
6 A 29-JUL-05Still not actually refreshing somehow.
I may play with this some more, it seems truly strange to me.
John -
Materialized view is not taking the Index
Hi Friends,
I have a materialized View for my Sales Details. I created a view on the Materialized View and using in my report. The Performance is very slow. After little research,
I found that the indexes are not used when the MV is accessed in the SQL. I tried explain plan for a very simple query on the view to prove that.
Here is my simple query.
select month_num ,sum(qty) from v_mv_sales_table
where month_num=201301
by month_num;
When I checked for count() it is considering the index and performance is good.
select month_num ,count(*) from v_mv_sales_table
where month_num=201301
by month_num;
Then I tried using hint for forcing the index. That time also it is working only for count not for SUM.
select /* +INDEX(tr, IDX2_MV_SALES_TABLE) */ month_num,count(*)
v_mv_sales_table tr
month_num=201301
by month_num;
Is there any way , I can force my sql to use the index on the month_num column?.
I have a question about using hint to force the sql.
My Question is I have indexes on my Materialized View. But I am using the hint on my view based on the Mat View.
Will it be okay to use like that?.
You may ask why I am using View instead of using Mat View directly. At later stage we are planning to apply some user level restrictions to the data
by linking the view to some other tables/view. So I am forced to use the View instead of MV.
Any ideas or suggestions will be good
Thanks in advance,
Vimal....here's an example
SQL> set autot off
SQL>
SQL> create table t
2 (dt date)
3 /
Table created.
SQL>
SQL> insert into t
2 select trunc (sysdate) + rownum
3 from all_objects
4 /
25707 rows created.
SQL>
SQL>
SQL> create index tidx on t (trunc (dt))
2 /
Index created.
SQL>
SQL> begin
2 dbms_stats.gather_table_stats (user, 'T');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> set autot trace expl
SQL> select *
2 from t
3 where dt = to_date ('24-07-2009', 'dd-mm-yyyy')
4 /
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=6 Card=1 Bytes=8)
1 0 TABLE ACCESS (FULL) OF 'T' (Cost=6 Card=1 Bytes=8)
SQL>
SQL> select *
2 from t
3 where dt = trunc (sysdate)
4 /
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=6 Card=1 Bytes=8)
1 0 TABLE ACCESS (FULL) OF 'T' (Cost=6 Card=1 Bytes=8)
SQL>
SQL> select *
2 from t
3 where trunc (dt) = trunc (sysdate)
4 /
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=2 Card=1 Bytes=
8)
2 1 INDEX (RANGE SCAN) OF 'TIDX' (NON-UNIQUE) (Cost=1 Card=1
SQL>
SQL>
SQL> drop table t
2 /
Table dropped.
SQL> -
Refresh time for Materialized View
Hi,
I have created a materialized view and set it to refresh everyday at 4 am . When I check the status of the job , it shows the refresh timing between 20 mins to 4 hours . That means , some times it takes 20 mins to refresh , some times 40 , some time 2 hours and some times up to 4 hours. Any reason for the wide range ? Here is the query for the view.
CREATE MATERIALIZED VIEW BDS_COST_CATEGORY_MV
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
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
REFRESH COMPLETE ON DEMAND START WITH sysdate+0 NEXT ROUND(SYSDATE + 1) + 4/24
USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS SELECT AC.ACCOUNT_MANAGER, AC.ACCOUNT_NUMBER,
AC.ACCOUNT_NAME, DIV.DIVISION_NUMBER, ITEM.CODE_ID,
ITEM.CODE_NAME COST_CATEGORY_ITEM,
TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')) PERIOD_YEAR,
AP.FIRST_DAY PERIOD,
SUM(NVL(AD.CURRENT_EXPENSE,0)) EXPENSE
FROM ACCOUNTS AC, PERSONNEL AC_MGR, DIVISIONS DIV, ASR_HEADERS AH , ASR_DETAILS AD, CODES ITEM, CODES COSTCAT, ALL_PERIODS AP,
CODES COST_ELEMENT, ACCOUNTING_BASE_GROUP ABG
WHERE AC.ACCOUNT_MANAGER = AC_MGR.PERSONNEL_ID
AND AC_MGR.DIVISION_ID = DIV.DIVISION_ID (+)
AND AC.ACCOUNT_ID = AH.ACCOUNT_ID
AND AH.ASR_HEADER_ID = AD.ASR_HEADER_ID
AND AH.PERIOD_ASR = AP.FISCAL_SYSTEM_PERIOD_CAL_YR_EQ||', '|| AP.FISCAL_YEAR
AND ABG.COST_ELEMENT_CAT_ITEM_ID = ITEM.CODE_ID
AND COST_ELEMENT.CODE_ID = ABG.COST_ELEMENT_ID
AND AD.OBJECT_CODE = COST_ELEMENT.CODE_VALUE
AND ITEM.CODE_PARENT_ID = COSTCAT.CODE_ID
AND ( COSTCAT.CODE_NAME = 'BDS' OR ( COSTCAT.CODE_NAME = 'Base' AND ITEM.CODE_NAME = 'MTDC'))
GROUP BY AC.ACCOUNT_MANAGER,AC.ACCOUNT_NUMBER, AC.ACCOUNT_NAME,
DIV.DIVISION_NUMBER, ITEM.CODE_ID, ITEM.CODE_NAME,
TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')), AP.FIRST_DAYThis appears to be a duplicate of Refreshing Materilized view. I replied on the other thread.
Justin -
Materialized view (fast refresh mode) + Materialized view log on another DB
Hi all,
I created a materizalied view using this script :
CREATE MATERIALIZED VIEW GIPS.DOSSIER_MEDICAL_MV2
TABLESPACE GIPS_T
NOCACHE
NOLOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
USING INDEX
TABLESPACE GIPS_I
+ REFRESH FAST ON DEMAND +
START WITH TO_DATE('11-janv.-2011 16:00:00','dd-mon-yyyy hh24:mi:ss')
NEXT sysdate (1/96)+
AS
SELECT N0_SEQ_BLOB_PDF,
EXAM_ID,
MPR,
RSM,
rub,
date_deb,
SPE,
commentaire,
SPR,
MEP,
MSJ,
TTD,
exam_type
FROM DOSSIER_MEDICAL@dbdoc_lk
WHERE DOSSIER_MEDICAL.EXAM_TYPE IN ('TELEM', 'SCANNER', 'EPPO_SECMED');
So you can see I'm using a dblink in the select statement ( DBDOC_LK )
On the DB referenced by this dblink, I created a materialized view log using this script :
CREATE MATERIALIZED VIEW LOG ON "DOSMED"."DOSSIER_MEDICAL"
TABLESPACE "DOC_T"
WITH PRIMARY KEY
INCLUDING NEW VALUES;
The problem is that my materialized view has never refreshed since its creation ! and I don't understand why ?
Can someone help me ?
Thank you.The REFRESH schedule causes a job to be created for the execution of the Refresh. You should see this job in DBA_JOBS / USER_JOBS.
The job would run only if the instance parameter JOB_QUEUE_PROCESSES is set to 1 or higher (the default is 0). This parameter can be modified dynamically with an ALTER SYSTEM command.
Hemant K Chitale
http://hemantoracledba.blogspot.com -
Table and Materialized View in different namespaces?
I've just faced something completly new for me. It appears that there are two objects with the same name and owner. Table and Materialized View have the same names and when I look into system dictionary I can se sth. like that:
OWNER OBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE NAMESPACE
USER_A USER_TABLE 159381 159381 TABLE 1
USER_A USER_TABLE 159382 MATERIALIZED VIEW 19
(I couldn't find how to write above with const length font).
Two object in different namespace? I thought that Tables and Materialized Vievs have the same namespace.
Can you please tell me how can I create objects to achieve above result? I would also be grateful if you tell me where to find that topic in documentation.Perfectly normal.
SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
no rows selected
SQL>
SQL> create materialized view test_mv
2 as
3 select sysdate from dual;
Materialized view created.
SQL>
SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
OBJECT_NAME OBJECT_TYPE
TEST_MV TABLE
TEST_MV MATERIALIZED VIEW
SQL>
SQL> drop materialized view test_mv;
Materialized view dropped.
SQL>
SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
no rows selected
SQL> -
Error while creating materialized view which using database link
Helo!
I'm getting error "ORA-00942: table or view does not exist" when I want to create materialized view.
Details:
1. On destination database I create a database link:
CREATE DATABASE LINK SDATABASE
CONNECT TO MYUSER
IDENTIFIED BY MYUSERPASS
USING 'ORCL';
=> Command "SELECT * FROM TABLE1@SDATABASE" returns data normally!
2. On source database I create MATERIALIZED VIEW LOG:
CREATE MATERIALIZED VIEW LOG
ON TABLE1
WITH PRIMARY KEY
INCLUDING NEW VALUES;
3. Now, when I want to create MATERIALIZED VIEW on destination database:
CREATE MATERIALIZED VIEW TABLE1
REFRESH FAST
START WITH SYSDATE
NEXT SYSDATE + 1/1440
WITH PRIMARY KEY
AS SELECT * FROM TABLE1@SDATABASE;
...I get error "ORA-00942: table or view does not exist"!
How is that possible if command "SELECT * FROM TABLE1@SDATABASE" returns data normally?
Thanks,
VorancAnd, I'm using Oracle 10g.
Voranc -
How to get a materialized view get to refresh itself after the job is "broken"
we created a materialized view sometime ago with the following statement:
create materialized view SXV_PUB_EMPLOYEE_CERT_ALL_M
refresh complete on demand
start with to_date('30-08-2009 04:00:00', 'dd-mm-yyyy hh24:mi:ss') next trunc(sysdate) + (28/24)
as
select sxv_emp_cert_all.*
from sxv_employee_certification_all sxv_emp_cert_all;
this week we found out it had not been refresh for about a month
In dba_jobs the column broken was 'Y', next_date time something like 01-01-4000 and failures 16
when I ran it manually by executing
BEGIN DBMS_MVIEW.REFRESH('SXV_PUB_EMPLOYEE_CERT_ALL_M', 'C'); END;
I found that one of the columns was too small (probably a columns of one of the underlying tables had been extended since the creation of the materialized view)
After fixing this I ussied yesterday (on 29-8-2013) the statement :
alter materialized view SXV_PUB_EMPLOYEE_CERT_ALL_M
refresh complete on demand
start with to_date('30-08-2009 04:00:00', 'dd-mm-yyyy hh24:mi:ss') next trunc(sysdate) + (28/24)
after this the table dba_jobs showed me 30-08-2013 04:00:00 as next date
I was expecting it to run this night at 04:00, but it didn't
the last_date column value was still from about a month ago, the column broken still shows 'Y'
and the next date 30-08-2013 04:00:00 (while it should been set to 31-08-2013 01:00:00
Rrunning
BEGIN DBMS_MVIEW.REFRESH('SXV_PUB_EMPLOYEE_CERT_ALL_M', 'C'); END;
gave no errors this time
and in User_Mview_Analysis the last_refresh_date column showed the date/time I had executed it
Any idea how to get the job "unbroken" again so that the view refreshes itself every night?
the database is Oracle Database 10g Release 10.2.0.4.0
regards,
Remcothanx for all your helpful and correct answers . but eventually I found it myself
exec dbms_job.broken(<jobnumber>, false); -
ORA-00905: missing keyword error while creating a materialized view
Hi Gurus,
I am trying to create a materialized view as :
1 CREATE MATERIALIZED VIEW AMREG.ClientData
2 TABLESPACE AMREG_DATA
3 COMPRESS
4 PARALLEL
5 NOLOGGING
6 BUILD IMMEDIATE
7 REFRESH COMPLETE
8 ON DEMAND
9 DISABLE QUERY REWRITE
10 REFRESH START WITH TRUNC( SYSDATE + 1 ) + 3/24 NEXT TRUNC( SYSDATE + 1 ) + 3/24
11 AS
12 SELECT
13 CHILD.CLIENT_SGK "Child SGK",
14 CHILD.CLIENT_NAME "Child Name",
15 CHILD.ARC_ACCT_CD "Child ARC Acct Code",
16 ULTIMATE.CLIENT_SGK "Ultimate Parent SGK",
17 ULTIMATE.CLIENT_NAME "Ultimate Parent Name",
18 ULTIMATE.ARC_ACCT_CD "Ultimate ARC Acct Code",
19 HIER.LVL_FROM_ANCESTOR ,
20 FROM [email protected] CHILD,
21 [email protected] HIER,
22 [email protected] ULTIMATE
23 WHERE HIER.DESCENDANT_CLIENT_SGK = CHILD.CLIENT_SGK
24* AND ULTIMATE.CLIENT_SGK = HIER.ANCESTOR_CLIENT_SGK;
SQL> /
REFRESH START WITH TRUNC( SYSDATE + 1 ) + 3/24 NEXT TRUNC( SYSDATE + 1 ) + 3/24
ERROR at line 10:
ORA-00905: missing keyword
DBLink name is : DNYCPH60.WORLD
Please guide me on this and help to resolve the issue.Ummm how about not posting the same question 4 times in 3 different forums?
Gints Plivna
http://www.gplivna.eu -
Long time for creation of materialized view
Hi,
we are trying to create a materialized view and this view would contain 1 lakh records and around 50 columns.
The select statement to get these records takes only 1-2 sec whereas the actual creation of view takes 17 minutes. The database used is Oracle 8i. The code used is
CREATE MATERIALIZED VIEW employee_master_t
PCTFREE 10
STORAGE (initial 500k next 500k pctincrease 0)
REFRESH WITH ROWID COMPLETE START WITH SYSDATE
NEXT SYSDATE + 1 AS select * from table_name
Is it because the insert is slow and temp tablespace may have to be increased?
also, can anyone pls suggest if fast refresh mode can be used with Oracle 8i since currently we are not able to create as error saying that query is complex is returnedIt will be possible to create a Materialised view with up to 20 tables, but you have to understand the restrictions on complex Materialised views with regards to fast refresh.
To help your understanding, refer to Materialized View Concepts and Architecture
<br>
Oracle Database FAQs
</br> -
Error on creation of Materialized view
Hi all, how are u? :-D
Well, I´m trying to use MATERIALIZED VIEW with refresh fast,
when first I grant permissions on the table action to an user,
after I create the MATERIALIZED VIEW LOG on the master and, finally,
I create the MATERIALIZED VIEW on the target.
-- using other_user:
GRANT SELECT, INSERT, UPDATE, DELETE ON action TO an_user;
CREATE MATERIALIZED VIEW LOG ON action
WITH PRIMARY KEY;
-- using an_user:
CREATE MATERIALIZED VIEW vw_action
REFRESH FAST
START WITH sysdate
NEXT TRUNC(sysdate) + 1/24
AS SELECT * FROM other_user.action;But, when I perform the CREATE MATERIALIZED VIEW the following error occurs:
ERROR at line 5:
ORA-12018: following error encountered during code generation for "AN_USER"."VW_ACTION"
ORA-00942: table or view does not exist
When I execute the query SELECT * FROM other_user.action, the data are returned.
What can it to be?
What´s the problem in this case?
Thank you very much!
[]´sHi Nicolas,
Well, I´m using Oracle 9.2.0.1 with Linux Red Hat.
I tryid without synonym and with synonym too, but...
I´m gonna to search for a solution.
And I´m gonna to try use the action recommended by oracle:
ORA-12015 cannot create a fast refresh materialized view from a complex query
Cause: Neither ROWIDs nor primary key constraints are supported for complex queries.
Action: Reissue the command with the REFRESH FORCE or REFRESH COMPLETE option or create a simple materialized view.thank you very much!
[]´s -
Peformance of a Materialized view
Hi,
I have created materialized view the below
CREATE MATERIALIZED VIEW SUMMARY.V_OSFI_FEED_CORE_DATA_ADJ
TABLESPACE RCDW_CAD_SUM_1M_DAT01
PCTUSED 0
PCTFREE 0
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD DEFERRED
REFRESH FORCE ON DEMAND
WITH PRIMARY KEY
AS
/* Formatted on 2010/01/27 14:49 (Formatter Plus v4.8.8) */
SELECT orgn.month_end_date month_end_date,
orgn.ntrl_k_odc_instrument ntrl_k_odc_instrument,
orgn.processing_system processing_system,
orgn.source_system source_system,
DECODE (UPPER (adjstd.ssb_type_indicator),
'NULL', NULL,
NVL (adjstd.ssb_type_indicator, orgn.ssb_type_indicator)
) ssb_type_indicator,
DECODE (UPPER (adjstd.basel_exposure_class),
'NULL', NULL,
NVL (adjstd.basel_exposure_class, orgn.basel_exposure_class)
) basel_exposure_class,
DECODE (UPPER (adjstd.basel_exposure_subclass),
'NULL', NULL,
NVL (adjstd.basel_exposure_subclass,
orgn.basel_exposure_subclass
) basel_exposure_subclass,
DECODE (UPPER (TRIM (adjstd.ccis_product_code)),
'NULL', NULL,
NVL (adjstd.ccis_product_code, orgn.ccis_product_code)
) ccis_product_code,
orgn.warehouse_instrument_key warehouse_instrument_key,
DECODE (UPPER (adjstd.instrument_status),
'NULL', NULL,
NVL (adjstd.instrument_status, orgn.instrument_status)
) instrument_status,
DECODE (UPPER (adjstd.instrument_open_flag),
'NULL', NULL,
NVL (adjstd.instrument_open_flag, orgn.instrument_open_flag)
) instrument_open_flag,
DECODE (UPPER (adjstd.instrument_dwo_flag),
'NULL', NULL,
NVL (adjstd.instrument_dwo_flag, orgn.instrument_dwo_flag)
) instrument_dwo_flag,
DECODE (UPPER (adjstd.instrument_closed_flag),
'NULL', NULL,
NVL (adjstd.instrument_closed_flag,
orgn.instrument_closed_flag)
) instrument_closed_flag,
DECODE (UPPER (adjstd.instrument_arrears_flag),
'NULL', NULL,
NVL (adjstd.instrument_arrears_flag,
orgn.instrument_arrears_flag
) instrument_arrears_flag,
DECODE (UPPER (adjstd.instrument_npna_flag),
'NULL', NULL,
NVL (adjstd.instrument_npna_flag, orgn.instrument_npna_flag)
) instrument_npna_flag,
DECODE (UPPER (adjstd.account_open_dt),
'NULL', TO_DATE (NULL),
NULL, orgn.account_open_dt,
TO_DATE (adjstd.account_open_dt, 'dd-MON-YYYY')
) account_open_dt,
DECODE (UPPER (adjstd.account_close_dt),
'NULL', TO_DATE (NULL),
NULL, orgn.account_close_dt,
TO_DATE (adjstd.account_close_dt, 'dd-MON-YYYY')
) account_close_dt,
DECODE (UPPER (adjstd.instrument_insured_ind),
'NULL', NULL,
NVL (adjstd.instrument_insured_ind,
orgn.instrument_insured_ind)
) instrument_insured_ind,
DECODE
(UPPER (adjstd.instrument_securitized_ind),
'NULL', NULL,
NVL (adjstd.instrument_securitized_ind,
orgn.instrument_securitized_ind
) instrument_securitized_ind,
DECODE (UPPER (adjstd.country_code),
'NULL', NULL,
NVL (adjstd.country_code, orgn.country_code)
) country_code,
DECODE (UPPER (TRIM (adjstd.province)),
'NULL', NULL,
NVL (adjstd.province, orgn.province)
) province,
COALESCE (adjstd.presec_outstanding_bal,
orgn.presec_outstanding_bal,
NULL
) presec_outstanding_bal,
COALESCE (adjstd.postsec_outstanding_bal,
orgn.postsec_outstanding_bal,
NULL
) postsec_outstanding_bal,
COALESCE (adjstd.presec_authorized_limit,
orgn.presec_authorized_limit,
NULL
) presec_authorized_limit,
DECODE (UPPER (adjstd.interest_rate_type),
'NULL', NULL,
NVL (adjstd.interest_rate_type, orgn.interest_rate_type)
) interest_rate_type,
COALESCE (adjstd.ltv, orgn.ltv, NULL) ltv,
DECODE (UPPER (adjstd.arrears_cycle_type),
'NULL', NULL,
NVL (adjstd.arrears_cycle_type, orgn.arrears_cycle_type)
) arrears_cycle_type,
COALESCE (adjstd.recovery_amt, orgn.recovery_amt, NULL) recovery_amt,
COALESCE (adjstd.wrtoff_amt, orgn.wrtoff_amt, NULL) wrtoff_amt,
COALESCE (adjstd.utilization_rate,
orgn.utilization_rate,
NULL
) utilization_rate,
DECODE (UPPER (adjstd.pd_pool),
'NULL', NULL,
NVL (adjstd.pd_pool, orgn.pd_pool)
) pd_pool,
COALESCE (adjstd.pd_value_pct, orgn.pd_value_pct, NULL) pd_value_pct,
DECODE (UPPER (adjstd.lgd_pool),
'NULL', NULL,
NVL (adjstd.lgd_pool, orgn.lgd_pool)
) lgd_pool,
COALESCE (adjstd.lgd_value_pct, orgn.lgd_value_pct,
NULL) lgd_value_pct,
DECODE (UPPER (adjstd.ead_pool),
'NULL', NULL,
NVL (adjstd.ead_pool, orgn.ead_pool)
) ead_pool,
COALESCE (adjstd.presec_precrm_ead,
orgn.presec_precrm_ead,
NULL
) presec_precrm_ead,
COALESCE (adjstd.postsec_precrm_ead,
orgn.postsec_precrm_ead,
NULL
) postsec_precrm_ead,
COALESCE (adjstd.postsec_postcrm_ead,
orgn.postsec_postcrm_ead,
NULL
) postsec_postcrm_ead,
COALESCE (adjstd.expected_loss_amt,
orgn.expected_loss_amt,
NULL
) expected_loss_amt,
COALESCE (adjstd.postsec_rwa, orgn.postsec_rwa, NULL) postsec_rwa,
DECODE (UPPER (adjstd.risk_rating_system),
'NULL', NULL,
NVL (adjstd.risk_rating_system, orgn.risk_rating_system)
) risk_rating_system,
DECODE (UPPER (adjstd.default_ind),
'NULL', NULL,
NVL (adjstd.default_ind, orgn.default_ind)
) default_ind,
DECODE (UPPER (adjstd.LOB),
'NULL', NULL,
NVL (adjstd.LOB, orgn.LOB)
) LOB,
DECODE (UPPER (adjstd.row_source),
'NULL', NULL,
NVL (adjstd.row_source, orgn.row_source)
) row_source,
COALESCE (adjstd.postsec_authorized_limit,
orgn.postsec_authorized_limit,
NULL
) postsec_authorized_limit,
COALESCE (adjstd.recovery_amt_calc,
orgn.recovery_amt_calc,
NULL
) recovery_amt_calc,
adjstd.adj_cycle_id adj_cycle_id,
orgn.curr_warehouse_inst_key curr_warehouse_inst_key,
orgn.curr_ccis_prod curr_ccis_prod, adjstd.load_time load_time,
adjstd.update_time update_time
FROM summary.osfi_feed_core_data orgn, summary.ncr_adj_data adjstd
WHERE orgn.ntrl_k_odc_instrument = adjstd.ntrl_k_odc_instrument
UNION ALL
SELECT orgn.month_end_date, orgn.ntrl_k_odc_instrument,
orgn.processing_system, orgn.source_system, orgn.ssb_type_indicator,
orgn.basel_exposure_class, orgn.basel_exposure_subclass,
orgn.ccis_product_code, orgn.warehouse_instrument_key,
orgn.instrument_status, orgn.instrument_open_flag,
orgn.instrument_dwo_flag, orgn.instrument_closed_flag,
orgn.instrument_arrears_flag, orgn.instrument_npna_flag,
orgn.account_open_dt, orgn.account_close_dt,
orgn.instrument_insured_ind, orgn.instrument_securitized_ind,
orgn.country_code, orgn.province, orgn.presec_outstanding_bal,
orgn.postsec_outstanding_bal, orgn.presec_authorized_limit,
orgn.interest_rate_type, orgn.ltv, orgn.arrears_cycle_type,
orgn.recovery_amt, orgn.wrtoff_amt, orgn.utilization_rate,
orgn.pd_pool, orgn.pd_value_pct, orgn.lgd_pool, orgn.lgd_value_pct,
orgn.ead_pool, orgn.presec_precrm_ead, orgn.postsec_precrm_ead,
orgn.postsec_postcrm_ead, orgn.expected_loss_amt, orgn.postsec_rwa,
orgn.risk_rating_system, orgn.default_ind, orgn.LOB, orgn.row_source,
orgn.postsec_authorized_limit, orgn.recovery_amt_calc, 0,
orgn.curr_warehouse_inst_key curr_warehouse_inst_key,
orgn.curr_ccis_prod curr_ccis_prod, SYSDATE, SYSDATE
FROM osfi_feed_core_data orgn
WHERE NOT EXISTS (SELECT ntrl_k_odc_instrument
FROM ncr_adj_data
WHERE ntrl_k_odc_instrument = orgn.ntrl_k_odc_instrument);When i refresh the materialized view its taking 5 to 6 mins. I have used DBMS_ADVISOR.TUNE_MVIEW to tune the query, but it raised error as
ORA-13600: error encountered in Advisor
QSM-03113: Cannot tune the MATERIALIZED VIEW statement
QSM-02091: mv references a non-repeatable or session-sensitive expression
QSM-02164: the materialized view is BUILD DEFERRED
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 202
ORA-06512: at "SYS.PRVT_TUNE_MVIEW", line 1232
ORA-06512: at "SYS.DBMS_ADVISOR", line 753
ORA-06512: at line 221
Can anyone suggest some methods to increase the peformance of the view.Hi,
Here is the explain plan of the query,
Plan
SELECT STATEMENT ALL_ROWSCost: 626 Bytes: 35,803,043 Cardinality: 144,937
18 PX COORDINATOR
17 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002
16 BUFFER SORT PARALLEL_COMBINED_WITH_PARENT Cost: 626 Bytes: 35,803,043 Cardinality: 144,937
15 UNION-ALL PARALLEL_COMBINED_WITH_PARENT
7 HASH JOIN PARALLEL_COMBINED_WITH_PARENT Cost: 314 Bytes: 7,803 Cardinality: 17
4 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD
3 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT Cost: 3 Bytes: 3,859 Cardinality: 17
2 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 3 Bytes: 3,859 Cardinality: 17
1 TABLE ACCESS FULL TABLE SUMMARY.NCR_ADJ_DATA Cost: 3 Bytes: 3,859 Cardinality: 17
6 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD Cost: 310 Bytes: 33,625,384 Cardinality: 144,937
5 TABLE ACCESS FULL TABLE PARALLEL_COMBINED_WITH_PARENT SUMMARY.OSFI_FEED_CORE_DATA Cost: 310 Bytes: 33,625,384 Cardinality: 144,937
14 HASH JOIN RIGHT ANTI PARALLEL_COMBINED_WITH_PARENT Cost: 312 Bytes: 35,795,240 Cardinality: 144,920
11 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD
10 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT Cost: 1 Bytes: 255 Cardinality: 17
9 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10001 Cost: 1 Bytes: 255 Cardinality: 17
8 INDEX FULL SCAN INDEX SUMMARY.INDEX_2 Cost: 1 Bytes: 255 Cardinality: 17
13 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD Cost: 310 Bytes: 33,625,384 Cardinality: 144,937
12 TABLE ACCESS FULL TABLE PARALLEL_COMBINED_WITH_PARENT SUMMARY.OSFI_FEED_CORE_DATA Cost: 310 Bytes: 33,625,384 Cardinality: 144,937 There is no index on the tables and it contains lakhs of records. -
Referencing a column of a materialized view
Hi,
I have a master table in a database A
CREATE TABLE formations (
nom_formation VARCHAR2(30) CONSTRAINT formations_nom_pk PRIMARY KEY
I have made a materialized view of that table in a remote database B
CREATE MATERIALIZED VIEW formations_mv
In the database B I also want to have this table
CREATE TABLE etudiants (
matricule NUMBER CONSTRAINT etudiants_matricule_pk PRIMARY KEY,
nom_formation VARCHAR2(30) CONSTRAINT etudiants_nom_formation_fk REFERENCES formations_mv(nom_formation)
But when I try to create the table etudiants I get an error on the foreign key that references a column in the materialized view formations_mv.
Is it impossible to reference a column in a materialized view from another table ?
Thanks.Hi,
In database B this is how I create formations_mv
CREATE MATERIALIZED VIEW formations_mv
REFRESH FAST
START WITH SYSDATE
NEXT (SYSDATE + 1 / 24 / 60)
WITH PRIMARY KEY
AS
SELECT *
FROM formations@etudiants_casa_db_link;
And in database A I create a materialized view log as
CREATE MATERIALIZED VIEW LOG ON formations
WITH PRIMARY KEY
INCLUDING NEW VALUES;
Maybe you are looking for
-
Multi-mapping....2nd mapping not executing
Hi all.. I am doing Proxy to file scenario.... I am using multi-mapping in this.. one source..... 2 targets i am triggering the taregt based on a field value( using equalsS and IF) if i am testing it with single value then the mapping is success and
-
Is there any option available to wrap the tab name in 11g?
-
Dgmgr - physical standby database
Hi, We are having Oracle 10g R2 (latest patch) . We have created a primary - physical standby database configuration. While the show database verbose 'dbname' in dgmgrl shows "success" for standby , it flags the following error for the primary Warnin
-
Cross-platform file opening issues?
Hi all, I have created some files in CS3 on a Mac (OS 10.5.8). They are fairly simple manual pages, just text, no graphics. I've sent them to a colleague to open on his PC, also running CS3, but he can't open them – he gets the message 'Cannot open f
-
Keywording with Proper Nouns?
Hi, folks. I'm trying to keyword people's full names in a hierarchical structure but am having problems with the sorting feature in Bridge CS5 because I can't stack the surnames together, only the given names. Thus, "Jane Doe" and "Jane Smith" are r