Oracle - I can't use Materialized View's PREBUILD statement with other MV clauses
I'm trying to build a Materialized View on top of a prebuilt table. I can use the below syntax with no modifiers and it works fine.
CREATE MATERIALIZED VIEW TESTRESULT
ON PREBUILT TABLE
SELECT ...
FROM ...
WHERE ...
However, when adding extra clauses to the Materialized View, I get the error "Missing Keyword". I'm not sure what I'm missing and I can't find any documentation online in conjunnction with building on top of a prebuilt table and adding extra clauses.
CREATE MATERIALIZED VIEW TESTRESULT
NOCACHE
LOGGING
NOCO开发者_Go百科MPRESS
NOPARALLEL
BUILD IMMEDIATE
REFRESH FORCE ON DEMAND
WITH PRIMARY KEY
ON PREBUILT TABLE
AS
SELECT ...
FROM ...
WHERE ...
Oracle Verision : 10g
The ON PREBUILT TABLE option is not compatible with some of your options, as described in the CREATE MATERIALIZED VIEW documentation:
- The CACHE, LOGGING, PARALLEL and COMPRESS are table properties inherited from the already built table and are therefore incompatible with PREBUILT.
- the BUILD option is there to specify when the table must be populated. However the table is already populated since you've used the PREBUILT option, and the two options are therefore incompatible.
Also make sure you have the arguments is the right order.
The following works:
SQL> CREATE TABLE TEST(ID NUMBER PRIMARY KEY);
Table created
SQL> CREATE TABLE testresult(ID NUMBER);
Table created
SQL> CREATE MATERIALIZED VIEW TESTRESULT
2 ON PREBUILT TABLE
3 REFRESH FORCE ON DEMAND
4 WITH PRIMARY KEY
5 AS
6 SELECT ID
7 FROM TEST;
Materialized view created
精彩评论