Create Materialzed view using WITH clause
How to create the Materialzed view using WITH clause? Using the below given code,
I'm not able to create the MV and it is disconnecing when trying to create the MV with the below code.
CREATE MATERIALIZED VIEW activity_mv
TABLESPACE DATA BUILD DEFERRED REFRESH FORCE ON DEMAND
WITH ROWID AS
WITH sum_sal AS (SELECT deptno , SUM(sal)sal_sum FROM emp GROUP BY deptno ),
cnt_emp AS (SELECT deptno , COUNT(sal)cnt_sal FROM emp GROUP BY deptno )
SELECT emp.deptno, emp.ename ,empno, sal
FROM emp , sum_sal rec1 , cnt_emp rec2
WHERE emp.deptno = rec1.deptno
AND rec1.deptno = rec2.deptno
AND sal > (sal_sum/cnt_sal )
Please let me know how to create it successfully and Oracle version is 184.108.40.206
Create Materialized View command requires a valid SELECT statement to populate it ... what happens if you run your populate statement independently?
Pablo (Paul) Berzukov
Author of Understanding Database Administration
available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
WITH clause is not a problem to create MV, check your syntax.
Originally Posted by malru
Click Here to Expand Forum to Full Width