Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORACLE : Materialized view- change START WITH CLAUSE

I created a Materialized view using the following code:

CREATE MATERIALIZED VIEW M_USER_HIERARCHY 

BUILD IMMEDIATE
REFRESH COMPLETE
START WITH TO_DATE('25-Aug-2009 10:34:24','dd-mon-yyyy hh24:mi:ss')
NEXT SYSDATE + 1     
WITH PRIMARY KEY
AS 
SELECT   * FROM V_USER_HIERARCHY;

However, I want to be able to change the START WITH date AFTER this code has been executed. I have been looking into the ALL_MVIEW_* tables but could not find where the setting for the START_DATE is.

Does anyone know how to change the START_WITH date of a Materialized View ?

like image 859
ddallala Avatar asked Aug 24 '09 14:08

ddallala


People also ask

Can you create or replace a materialized view?

No, you cannot alter the query of a materialized view without dropping it. The CREATE MATERIALIZED VIEW syntax does not support that feature. The ALTER MATERIALIZED VIEW is used to modify an existing materialized view in one or more of the following ways: To change its storage characteristics.

How do you update data in materialized view?

To update the data in a materialized view, you can use the REFRESH MATERIALIZED VIEW statement at any time. When you use this statement, Amazon Redshift identifies changes that have taken place in the base table or tables, and then applies those changes to the materialized view.

Can we create primary key on materialized view?

Primary key materialized views allow materialized view master tables to be reorganized without affecting the eligibility of the materialized view for fast refresh. The master table must contain an enabled primary key constraint. You cannot specify this clause for an object materialized view.


1 Answers

It's really quite straightforward.

SQL> create materialized view emp_data
  2  as select * from emp
  3  /

Materialized view created.

SQL> ALTER MATERIALIZED VIEW emp_data
  2     REFRESH COMPLETE
  3     START WITH TRUNC(SYSDATE+1) + 12/24
  4     NEXT SYSDATE+1
  5  /

Materialized view altered.

SQL>
like image 122
APC Avatar answered Oct 03 '22 03:10

APC