-
Create Materialzed view using WITH clause
Hi All,
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 9.2.0.7
Thanks...
-
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.
-
Originally Posted by malru
Hi All,
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 9.2.0.7
Thanks...
WITH clause is not a problem to create MV, check your syntax.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|