I created a materialized view log along with a materialized view called update_nboe based on table NBOE_ EMPLOYEES_TEST using the following code
CREATE MATERIALIZED VIEW LOG ON NBOE_EMPLOYEES_TEST WITH primary key;
CREATE MATERIALIZED VIEW update_nboe
REFRESH FAST ON DEMAND
AS
SELECT E.EMP_ID, E.USERNAME ,E.NAME, E.LOCATION , E.TITLE, E.LOCATION_CODE, E.RS_GROUP
FROM NBOE_EMPLOYEES_TEST E;
Then I updated NBOE_EMPLOYEES_TEST by inserting additional records hoping that the materialized view would update and refresh on-demand after using the following piece of code
exec dbms_mview.refresh('update_nboe',atomic_refresh_test=>TRUE);
However, I see a red cross on my connections panel for the materialized view and it won't refresh either.
Would appreciate some input.
Best Answer
We normally use jobs to automate MV refreshes, so you don't have to do them manually or on demand.
For example, if you want your MV to refresh every 4 hours, then you would submit a job like this. Connect as the schema owner of the MV.
The C denotes a complete refresh and you can use F for a fast refresh or check the docs for other possible parameters. I don't know why you chose atomic_refresh_test; this does not seem to be something you need.
Sometimes the jobs break and you would have to run the job again after refreshing the MV manually. This you can check from DBA_JOBS. This is code that checks for broken MV jobs and outputs the commands to fix them. Connect as the owner of the MV then run this code: