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 ?
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.
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With