Has anyone managed to create a materialized view with index organization ? I have an MV which only has one column, so I wanted it to be index organized, but I'm really struggling with the syntax for it. My latest attempt is:
Code:
create materialized view mv_annuity_tcns using index refresh on demand
organization index pctthreshold 90 including annuitytcn overflow tablespace sml_d
as
SELECT
DISTINCT
TRIM(COLUMN_72) ANNUITYTCN
FROM SRC_FEED_DATA
WHERE SRC_SYS_FEED_ID = 666
and TRIM(COLUMN_72) IS NOT NULL
Whatever I try, I get ORA-905, missing keyword. Unfortunately, it gives me no clue as to which keyword is missing and the manual is none too helpful.
Look carefully, I created an IOT table called test then created a MV on it. Yes, I created the MV table first then the source table for it called test_src. I don't think it makes a difference.
SQL> create table test (id number, column_72 varchar2(100))
2 tablespace users_std_Tbl;
Table created.
SQL>
SQL> alter table test add (
2 constraint test_pk
3 primary key (ID)
4 USING INDEX
5 PCTFREE 10
6 TABLESPACE users_std_tbl );
Table altered.
SQL> insert into test values (1, 'abc');
1 row created.
SQL> insert into test values (2,'def');
1 row created.
SQL> insert into test values (3, null);
1 row created.
SQL> COMMIT;
Commit complete.
SQL>
SQL> create materialized view mv_test
2 organization index
3 pctfree 10
4 pctthreshold 30
5 including tcol overflow tablespace users_std_tbl
6 using index
7 refresh on demand
8 as
9 SELECT id
10 , trim(column_72) tcol
11 FROM test
12 WHERE id = 2
13 and TRIM(COLUMN_72) IS NOT NULL ;
Thanks for all your help. I'm now getting a more helpful error message - "ORA-25175, no primary key constraint found". I think it must have been just the order of the keywords that was giving problems before. I'm not sure if there is anyway around the fact that the source table doesn't have a primary key. I could create an intermediate table, but that defeats the point of having a materialized view - I may as well just use the intermediate table.
Bookmarks