"Invalid Metadata Objects" when creating materialized views

Hi experts,
I have run into some trouble. I had an analytic workspace that grew too fast (see 11.2.0.2 AW size grows steadily with every cube build so I deleted it and created a new one.
It seemed to build fine using the tip that David Greenfield gave us in the mentioned forum post, but when I try to enable materialized views (which I had enabled in the previous workspace) I'm gettig the following error:
Your metadata changes have been saved, with the following errors
Invalid Metadata Objects:
Invalid Object "TABLESPACE.LECTURAS": "CREATE MATERIALIZED VIEW "TABLESPACE"."CB$LECTURAS"
ORGANIZATION CUBE ON TABLESPACE.TABLESPACE_AW(
FACT "LECTURAS_STORED"("LECTURAS_MEASURE_DIM" 'LECTURA') IS "LECTURA",
DIMENSION "TIEMPO" IS "TIEMPO" USING "TIEMPO_TIEMPO_HOUR_ID_UNIQUE_KEY" ,
DIMENSION "GEOGRAFIA" IS "GEOGRAFIA" USING "GEOGRAFIA_GEOGRAFIA_CONTADOR_ID_UNIQUE_KEY" )
BUILD DEFERRED
REFRESH ON DEMAND
FORCE
USING TRUSTED CONSTRAINTS
AS
SELECT
TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') "TIEMPO",
T1."COD_METERID" "GEOGRAFIA",
SUM(T1."VAL_AI_HOR") "LECTURA"
FROM
TABLESPACE."LECTURA_HORARIA_FINAL" T1
GROUP BY
(TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') , T1."COD_METERID")
ORA-00942: table or view does not exist
Running this same script in SQLDeveloper yields the same error at line 17, which is the FROM clause. BUT I can run the SELECT statement by itself and returns the expected result. So the table exists in the correct tablespace.
I must be missing something big...
Thanks in advance.
Joan
P.S.: In the code above I'm using "TABLESPACE" in substitution for the real username and tablespace name (which is the same) for privacy reasons.

When you ran the select statement, were you connected as the same user that you used to try to enable the MVs?
Can you create a standard (non cube) MV with the same select statement? (Connected as the same user you used in AWM.)
"CREATE MATERIALIZED VIEW "TABLESPACE"."MV_TEST"
  BUILD DEFERRED
  REFRESH ON DEMAND
  FORCE
  USING TRUSTED CONSTRAINTS
AS
  SELECT
   TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') "TIEMPO",
   T1."COD_METERID" "GEOGRAFIA",
   SUM(T1."VAL_AI_HOR") "LECTURA"
  FROM
   TABLESPACE."LECTURA_HORARIA_FINAL" T1
  GROUP BY
   (TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') , T1."COD_METERID")
{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Error when Create Materialized View

    Hi
    When I tried to create MV show me error :
    SQL> @CRIA_MV_ARC_BW.SQL
    AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
    ERROR at line 88:
    ORA-01031: insufficient privilegesI am using Oracle 9.02 and there are Grant for all Tablles , my query of creation is:
    CREATE MATERIALIZED VIEW CLIBGF.MV_ARC_BW
    NOCACHE
    LOGGING
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH FORCE
    START WITH TO_DATE('26-nov-2009 02:00:00','dd-mon-yyyy hh24:mi:ss')
    NEXT trunc(sysdate) + 1/12
    ENABLE QUERY REWRITE
    AS
    SELECT     MAX(NVL((SELECT  DECODE(A.T$CDNG$O,'F',DECODE(TRIM(B.T$CALC$O),'S','C',A.T$CDNG$O),A.T$CDNG$O)
                     FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
                    WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
                      AND A.T$NDOC$O = NOTAS.CD_NOTA
                      AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)
                                        AND ROWNUM =1),
                   0)) NEGOCIO,
           ARC.CD_CLIENTE CD_CLIENTE,
           CLIENTE.T$NAMA DS_CLIENTE,
           ARC.CD_ARC,
           ARC.CD_STATUS,
           ARC.CD_STATUS || ' - ' || STATUS.DS_STATUS STATUS,
           TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY') DT_EMISSAO,
           TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY') DT_REALIZADO_INVESTIGACAO,
           ARC.CD_MARCA || ' - ' || MARCA.T$DSMA$O MARCA,
           ARC.CD_PRODUTO CD_PRODUTO,
           EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O DS_EMBALAGEM,
           SUBSTR(ARC.DS_ARC, 1, 3) CD_COMPANHIA_PRODUTORA,
            ARC.CD_MOTIVO_RECLAMACAO CD_MOTIVO_RECLAMACAO,
            MOTIVO.DS_ITEM DS_MOTIVO_RECLAMACAO,
           DECODE(ARC.FL_PROCEDENCIA, 0, 'PROCEDENTE', 1, 'IMPROCEDENTE', ' ') PROCEDENCIA,
           SUM(NVL((SELECT SUM(NVL(T$IQUA$O, 0))
                     FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
                    WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
                      AND A.T$NDOC$O = NOTAS.CD_NOTA
                      AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)),
                   0)) NR_QUANTIDADE_VENDIDA,
               ARC.NR_QUANTIDADE_AFETADA NR_QUANTIDADE_AFETADA,     
           ARC.NR_QUANTIDADE_AFETADA_REAL NR_QUANTIDADE_AFETADA_REAL,
           DS_JUSTIFICATIVA DSJUST
      FROM ARCTB_ARC                 ARC,
           ARCTB_NOTAS               NOTAS,
           ARCTB_TABELA_MOTIVO       MOTIVO,
           ARCTB_ACAO_IMEDIATA       ACAO_INV,
           ARCTB_ACAO_IMEDIATA       ACAO_IME,
           ARCTB_STATUS              STATUS,
           TRITON.TTCCOM010501       CLIENTE,
           TRITON.TTCCOM936501       CIDADE,
           TRITON.TTIITM001810       D,
           TRITON.TTIITM983501       PRODUTO,
           TRITON.TTFGLD010806       CC,
           TRITON.TTCCOM983501       MARCA,
           TRITON.TTCCOM000501       CIA,
           TRITON.TTIITM982501       NAT,
           SEI.SIBTB_MULTIMARCA      MULTIMARCA,
           SEI.SIBTB_DIRETORIA_DEPTO DIRETORIA,
           TRITON.TTCCOM994501       USUARIO,
           ARCTB_GERENCIA_INDUSTRIAL INDUSTRIAL,
           TRITON.TTIITM984501       EMBALAGEM
    WHERE ARC.CD_ARC = NOTAS.CD_ARC(+)
       AND ARC.CD_ARC = ACAO_INV.CD_ARC(+)
       AND ACAO_INV.CD_TIPO_ACAO(+) = 0
       AND ACAO_INV.CD_ACAO_IMEDIATA(+) = 999
       AND ARC.CD_ARC = ACAO_IME.CD_ARC(+)
       AND ACAO_IME.CD_TIPO_ACAO(+) = 1
       AND ACAO_IME.CD_ACAO_IMEDIATA(+) = 999
       AND ARC.CD_CLIENTE = CLIENTE.T$CUNO(+)
       AND CLIENTE.T$ESTA$L = CIDADE.T$ESTA$L(+)
       AND CLIENTE.T$CDMU$L = CIDADE.T$MUNI$L(+)
       AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
           TRIM(REPLACE(D.T$ITEM(+), '-', ''))
       AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
           TRIM(REPLACE(PRODUTO.T$ITEM$O(+), '-', ''))
       AND PRODUTO.T$PROC$O = NAT.T$PROC$O(+)
       AND EMBALAGEM.T$CDAC$O(+) = PRODUTO.T$CDAC$O
       AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
       AND ARC.CD_MARCA = MARCA.T$CDMA$O(+)
       AND SUBSTR(ARC.DS_ARC, 1, 3) = CIA.T$NCMP(+)
       AND ARC.CD_STATUS = STATUS.CD_STATUS(+)
       AND TRIM(ARC.CD_CENTRO_CUSTO) = TRIM(CC.T$DIMX(+))
       AND CC.T$DTYP(+) = 2
       AND CC.T$SUBL(+) = 0
       AND ARC.CD_DEPTO_MULTIMARCA = MULTIMARCA.CD_MULTIMARCA(+)
       AND ARC.CD_DEPTO = DIRETORIA.CD_DEPTO(+)
       AND ARC.CD_USUARIO = TRIM(USUARIO.T$CDUS$O(+))
       AND ARC.CD_STATUS IS NOT NULL
       AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
       AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
       GROUP BY TO_CHAR(ARC.DT_EMISSAO, 'YYYY'),
              TO_CHAR(ARC.DT_EMISSAO, 'MM'),
              ARC.CD_ARC,
              ARC.DS_ARC,
              ARC.DS_SUPERVISOR,
              ARC.CD_STATUS,
              STATUS.DS_STATUS,
              TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_INV.DT_ORIGINAL, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_IME.DT_ORIGINAL, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_IME.DT_REALIZADO, 'DD/MM/YYYY'),
              TO_CHAR(ARC.DT_PROCEDENCIA, 'DD/MM/YYYY'),
              TO_CHAR(ARC.DT_RECEBIMENTO, 'DD/MM/YYYY'),
              TO_CHAR(NVL(ARC.DT_APROVACAO_INDUSTRIAL,
                          ARC.DT_APROVACAO_COMERCIAL),
                      'DD/MM/YYYY'),
              ARC.CD_CLIENTE,
              CLIENTE.T$NAMA,
              CIDADE.T$DSCA$L,
              ARC.CD_MARCA,
              MARCA.T$DSMA$O,
              ARC.CD_PRODUTO,
              D.T$SEAK,
              EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O,
              NAT.T$DESC$O,
              ARC.NR_LOTE,
              ARC.DT_FABRICACAO,
              SUBSTR(ARC.DS_ARC, 1, 3),
              CIA.T$CITY,
              ARC.CD_MOTIVO_RECLAMACAO,
              MOTIVO.DS_ITEM,
              DECODE(ARC.FL_PROCEDENCIA,
                     0,
                     'PROCEDENTE',
                     1,
                     'IMPROCEDENTE',
              ARC.DS_DISPOSICAO,
              ARC.CD_CENTRO_CUSTO,
              CC.T$DESC,
              ARC.NR_QUANTIDADE_AFETADA,
              DS_JUSTIFICATIVA,
              DS_DISPOSICAO,
              CD_RESPONSAVEL_CAUSA,
              ARC.NR_QUANTIDADE_AFETADA_REAL,
              ARC.DT_ATENDIMENTO,
              MOTIVO.CLASSIFICACAO,
              ARC.DS_COORDENADOR,
              ARC.FL_ATENDIMENTO,
              TO_CHAR(ARC.DT_ATENDIMENTO, 'DD/MM/YYYY'),
              ARC.DS_COORDENADOR_INVESTIGACAO,
              INDUSTRIAL.REGIAO
    ORDER BY ARC.CD_ARC DESC;
    Edited by: muttleychess on Nov 25, 2009 10:25 AM

    Please see my privilege
    GRANTEE PRIVILEGE ADM
    CLIBGF CREATE TABLE NO
    CLIBGF CREATE ANY VIEW NO
    CLIBGF CREATE SNAPSHOT NO
    CLIBGF SELECT ANY TABLE NO
    CLIBGF CREATE ANY TRIGGER NO
    CLIBGF CREATE ANY SNAPSHOT NO

  • ORA-12052 when create materialized view

    I following the sample in Oracle document to create materialized viewCREATE MATERIALIZED VIEW LOG ON sales
       WITH ROWID, SEQUENCE(amount_sold, time_id, prod_id)   INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW LOG ON times
       WITH ROWID, SEQUENCE (time_id, calendar_year)  INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW LOG ON products
       WITH ROWID, SEQUENCE (prod_id,prod_name)  INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW sales_mv
       BUILD IMMEDIATE   REFRESH FAST ON COMMIT
       AS SELECT t.calendar_year, p.prod_id, p.prod_name,
          SUM(s.amount_sold) AS sum_sales
          FROM times t, products p, sales s
          WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id
          GROUP BY t.calendar_year, p.prod_id, p.prod_name; This works. BUt I actually does not want do aggregation. Thus I changed the MV creation statement toCREATE MATERIALIZED VIEW sales_mv
       BUILD IMMEDIATE REFRESH FAST ON COMMIT
       AS SELECT t.calendar_year, p.prod_id, p.prod_name,s.amount_sold
          FROM times t, products p, sales s
          WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id;I got errorSQL Error: ORA-12052: cannot fast refresh materialized view GLU.SALES_MV
    *Cause:    Either ROWIDs of certain tables were missing in the definition or
               the inner table of an outer join did not have UNIQUE constraints on
               join columns.
    *Action:   Specify the FORCE or COMPLETE option. If this error is got
               during creation, the materialized view definition may have be
               changed. Refer to the documentation on materialized views.Please help or point me to the relevant document.
    Thanks

    damorgan, Thank you for you reply.
    the inner table of an outer join did not have UNIQUE constraints on join columns.
    I am not sure how much clearer and explanation can be written.If you look at the query, you will find that there is no outer join in the query.
    sales table does not have unique constraints on prod_id and time_id. If this is the cause of the problem, I cannot change the data but is there a work around. That is way I ask for specific doc. In 11g documents, I only find some info on CREATE MV. That is mainly on syntax but not on requirement.

  • Insufficient Privileges when create materialized view as user system

    If I login as system (connect sys/****@DevDB) and try to create a materialized view for another schema (e.g. XDCONTROLDB), I get the insufficient privileges error. If I login as sys as sysdba then I can create successfully.
    I have searched some ariticles in Google and grant create any snapshot, create any table, create any view, global query rewrite, select any table system privileges to system but still get the same error.
    Any other privileges I need to grant to system?
    Cheers
    below is a sample script to create the view which get the error:
    CREATE MATERIALIZED VIEW XDControlDB."XDTest1" PCTFREE 10
    PCTUSED 0 MAXTRANS 255
    STORAGE ( INITIAL 64K NEXT 0K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0)
    TABLESPACE "USERS"
    BUILD IMMEDIATE
    REFRESH COMPLETE START WITH sysdate NEXT sysdate + 1/24
    ENABLE QUERY REWRITE AS
    SELECT * From XDControlDB.RiskInstance;
    Message was edited by:
    user500168
    Message was edited by:
    user500168

    Thanks for your reply. After I grant privileges to system, I login as system and try to create the view as below which I get the insufficient privileges error:
    CREATE MATERIALIZED VIEW XDControlDB."XDTest1" PCTFREE 10
    PCTUSED 0 MAXTRANS 255
    STORAGE ( INITIAL 64K NEXT 0K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0)
    TABLESPACE "USERS"
    BUILD IMMEDIATE
    REFRESH COMPLETE START WITH sysdate NEXT sysdate + 1/24
    ENABLE QUERY REWRITE AS
    SELECT 1 From XDControlDB.RiskInstance;
    As you can see, I try to create the view under a schema called 'XDCONTROLDB'. If I login as sys as sysdba, then it create successfully.
    After I create UserA, and grant the privileges I mentioned in the ealier post, I login as UserA, and run the statement above I get the same privileges error. But if I change the stament to below which will create the view under UserA's schema, then it create successfully:
    CREATE MATERIALIZED VIEW UserA."XDTest1" PCTFREE 10
    PCTUSED 0 MAXTRANS 255
    STORAGE ( INITIAL 64K NEXT 0K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0)
    TABLESPACE "USERS"
    BUILD IMMEDIATE
    REFRESH COMPLETE START WITH sysdate NEXT sysdate + 1/24
    ENABLE QUERY REWRITE AS
    SELECT 1 From XDControlDB.RiskInstance;
    Looking for your suggestions,
    Cheers

  • Ora-23454 when add an objects to the materialized view group

    Hi, All,
    I tend to create a distributed MV, when add an objects to the materialized view group using:
    BEGIN
    DBMS_REPCAT.CREATE_MVIEW_REPOBJECT (
    gname => 'hr_repg',
    sname => 'hr',
    oname => 'departments_mv1',
    type => 'SNAPSHOT',
    min_communication => TRUE);
    END;
    I got the follwoing errors:
    ORA-23454: flavor not defined for object group "PUBLIC"."HR_REPG"
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
    ORA-06512: at "SYS.DBMS_REPCAT_UTL", line 452
    ORA-06512: at "SYS.DBMS_REPCAT_UTL", line 468
    ORA-06512: at "SYS.DBMS_REPCAT_SNA_UTL", line 5599
    ORA-06512: at "SYS.DBMS_REPCAT_SNA", line 82
    ORA-06512: at "SYS.DBMS_REPCAT", line 1332
    ORA-06512: at line 2
    Does anybody know what is the problem?
    Thanks in advance for any advice.
    Sharon.Ni

    Are you trying to replicate an existing materialized view called "departments_mv1" ? That is what the implication of the arguments you are supplying.
    If it is an MV, you have to supply the DDL (in the DDL_TEXT) as well.
    Hemant K Chitale

  • Illegal use of LONG datatype error message when i create materialized view

    Hello to all
    I want create read only materialized view replication environment two of our tables have LONG datatype when i create materialized view against on them
    I recieve this error message
    CREATE MATERIALIZED VIEW MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID AS SELECT * FROM MDB.TOAD_PLAN_TABLE@arahisto
    Error report:
    SQL Error: ORA-00997: illegal use of LONG datatype
    00997. 00000 - "illegal use of LONG datatype"
    Do you know any resort solution for it?
    thanks

    You can not use longs in materialized views over a database link, you can however take a part of a long over to a materialized view.
    I have gotten this to work in the past l had to create a PL/SQL function that you can use to extract the character data from the long column and use that to
    as part of the function you will need to pass in the columns of the table that will identify the unique records so you can pick out the long column
    example function
    -- you will need to make sure this funtion is in the remote location as you can not select longs accross a DB LINK.
    CREATE OR REPLACE FUNCTION MDB.TOAD_PLAN_LONG_CONV
    (pass in the primary key columns for the table)
    RETURN VARCHAR2
    IS
    v_long VARCHAR2(32767) ;
    BEGIN
    BEGIN
    -- need to select the long column into the PL/SQL variable
    SELECT long_column
    INTO v_long
    FROM MDB.TOAD_PLAN_TABLE
    WHERE key_columns = passed columns ;
    EXCEPTION
    WHEN OTHERS THEN
    IF SQLCODE = '-01406' THEN
    NULL ;
    ELSE
    RAISE ;
    END IF ;
    END ;
    RETURN SUBSTR(v_long,1,4000) ;
    END ;
    Then when you create the materialized view utilize that function on the long column.
    create or replace materialized view MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID
    AS
    SELECT column1, .... columnx,
    MDB.TOAD_PLAN_LONG_CONV@arahisto (primary key column list) as long_column_name
    FROM MDB.TOAD_PLAN_TABLE@arahisto ;
    See if this will work for you? Keep in mind however this solution will not get the entire long column only as much as a PL/SQL variable will hold of it.
    Mike

  • Create materialized view is failing when refresh fast is used

    version 10.2.0.4 on solaris
    This statement is working fine
    CREATE MATERIALIZED VIEW MVIEW1
    TABLESPACE MIS_CURD01
    BUILD IMMEDIATE
    as
    SELECT ACTIVITY_ID "ACTIVITY_ID",
    ASSOC_ID "ASSOC_ID",
    PIT_ROLE_CODE "PIT_ROLE_CODE",
    PIT_BANK_CODE "PIT_BANK_CODE",
    PIT_COST_CENTER "PIT_COST_CENTER",
    RESP_ASSOC_IND "RESP_ASSOC_IND"
    FROM TABLE1@DBLINK;
    The statement with fast refresh is failing with this error message
    ERROR at line 18:
    ORA-12018: following error encountered during code generation for
    "TABLE1"
    ORA-00942: table or view does not exist
    Here is the statement
    CREATE MATERIALIZED VIEW MVIEW1
    TABLESPACE MIS_CURD01
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    USING INDEX TABLESPACE MIS_CURI01
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY
    AS
    SELECT ACTIVITY_ID "ACTIVITY_ID",
    ASSOC_ID "ASSOC_ID",
    PIT_ROLE_CODE "PIT_ROLE_CODE",
    PIT_BANK_CODE "PIT_BANK_CODE",
    PIT_COST_CENTER "PIT_COST_CENTER",
    RESP_ASSOC_IND "RESP_ASSOC_IND"
    FROM TABLE1@DBLINK;
    Any idea what's going wrong here. Thanks for your help in advance.
    Edited by: user11319873 on Jun 30, 2010 4:17 PM

    Refresh FAST requires that
    a. An MV Log (Snapshot Log) be created on the source table
    b. The user doing the refresh (i.e. the account that the DBLink uses) has SELECT privilege on the MV Log.
    Hemant K Chitale

  • ORA-25175 when trying to create materialized view, organization index SOLV

    Hi,
    I'm trying to create a materialized view to compensate for non-normalized table.
    I have table anormal, and mv is to be on distinct agency, company in that table.
    Here goes:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - Productio
    NLSRTL Version 10.2.0.3.0 - Production
    SQL> create table anormal (company varchar2(8) not null
      2                       ,dept varchar2(8) not null
      3                       ,agency varchar2(8) not null
      4                       ,constraint anormal_pk primary key (company,dept));
    Table created.
    SQL> insert into anormal values('c1', 1, 'Ajax');
    1 row created.
    SQL> insert into anormal values('c1', 2, 'Ajax');
    1 row created.
    SQL> insert into anormal values('c1', 3, 'Acme');
    1 row created.
    SQL> insert into anormal values('c2', 1, 'Acme');
    1 row created.
    SQL> insert into anormal values('c2', 2, 'Acme');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from anormal;
    COMPANY  DEPT     AGENCY
    c1       1        Ajax
    c1       2        Ajax
    c1       3        Acme
    c2       1        Acme
    c2       2        Acme
    SQL> create materialized view agency_comp_mv
      2  organization index --primary key (agency, company)
      3  build deferred
      4  refresh on demand
      5  as
      6  select distinct agency, company from anormal
      7  /
    select distinct agency, company from anormal
    ERROR at line 6:
    ORA-25175: no PRIMARY KEY constraint found
    SQL>The error tells me that there is no primary key, but is there any way to add such?
    - or is my problem rather that I cannot use DISTINCT with organization index?
    Regards
    Peter
    bump
    Message was edited by:
    Peter Gjelstrup
    <SOLVED>
    Message was edited by:
    Peter Gjelstrup

    Thanks William,
    I tried with ON PREBUILT TABLE, just to see what happens.
    Building on my OP:
    SQL> create table iot(agency varchar2(8) not null, company varchar2(8) not null
      2                  ,constraint iot_pk primary key (agency,company))
      3  organization index;
    Table created.
    SQL> insert into iot select distinct agency, company from anormal;
    4 rows created.
    SQL> commit;
    Commit complete.
    SQL> create materialized view iot on prebuilt table
      2  as
      3  select distinct agency, company from anormal;
    Materialized view created.
    SQL> select * from iot;
    AGENCY   COMPANY
    Acme     c1
    Acme     c2
    Ajax     c1
    SQL> insert into anormal values('c3', 2, 'Foo');
    insert into anormal values('c3', 2, 'Foo')
    1 row created
    SQL> select * from anormal;
    COMPANY  DEPT     AGENCY
    c1       1        Ajax
    c1       2        Ajax
    c1       3        Acme
    c2       1        Acme
    c2       2        Acme
    c3       2        Foo
    6 rows selected.
    SQL> select * from iot;
    AGENCY   COMPANY
    Acme     c1
    Acme     c2
    Ajax     c1
    3 rows selectedNow, try to refresh and MV
    SQL> alter materialized view iot refresh complete;
    Materialized view altered.
    SQL> select object_type, to_char(last_ddl_time, 'hh:mi:ss'), status
      2    from user_objects where object_name = 'IOT';
    OBJECT_TYPE         DDL_TIME STATUS
    TABLE               10:40:42 VALID
    MATERIALIZED VIEW   10:41:13 VALID
    SQL> select * from iot;
    AGENCY   COMPANY
    Acme     c1
    Acme     c2
    Ajax     c1Agency "Foo" is not in MV,
    Looks like that IOT select'ed from is indeed the MV:
    SQL> drop table iot;
    drop table iot
    ERROR at line 1:
    ORA-12083: must use DROP MATERIALIZED VIEW to drop "STIK"."IOT"
    SQL>So, seems that Maxim is right, it just can't be done. And it seems my options are:
    Create HEAP organized MV or
    Create and maintain IOT
    Regards
    Peter

  • Creating Materialized View in Toad

    As with every new endeavor - come new questions.
    I am trying to create a materialized view via toad (first time doing this). Now - toad is great, since it provides a kind-of wizard interface. Hence, one doesn't have to completely code in the create statement, with all of the options, etc.
    Instead, in toad, one can (via the schema browser), go into the Materialized Views tab and click on create new. This opens a window with 6 tabs: Basic Info, Refresh Info, Physical Attributes, Query, Partitions & Subpartition Template.
    In the Basic Info, one can put a check mark next to some of the following options:
    -Build Deffered
    -Parallel
    -Cache
    -Logging
    -Using index
    -Allow updates
    etc.
    I have read that build deferred refers to whether or not you would like the view to be created automatically or to be deferred.
    Anyways, I tried to find Toad documentation to explain each of the options in-detail. No success. Hence, am researching each part piece by piece.
    But - here is my question:
    In the Query tab, we are asked to specify a query. I am assuming that the query does not have to be a full query, beginning with CREATE MATERIALIZED VIEW mv_table1 REFRESH FAST etc...
    Since in this 'wizard', we are providing the MV name at the top of the dialog box, we are checking the 'options' in the other tabs, etc.
    And so, I assumed that the query should merely be a select query in the window mentioned above.
    So I entered the following:
    select * from table1@remote_db;
    When I go to verify the syntax, I get the error message: ORA_00911: invalid character. It seems to be pointing to my db_link (remote_db). I have been using this link throughout many places, w/o any problems.
    Has anyone created a MV in toad before? Any links to good toad documentation would be helpful as well.
    Thanks.

    (This is fun... ;))
    For anyone endeavoring this in the future, below I have attached the prerequisites required in order to create a materialized view (can also be found @ http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_6002.htm):
    Prerequisites
    The privileges required to create a materialized view should be granted directly rather than through a role.
    To create a materialized view in your own schema:
    You must have been granted the CREATE MATERIALIZED VIEW system privilege and either the CREATE TABLE or CREATE ANY TABLE system privilege.
    You must also have access to any master tables of the materialized view that you do not own, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a materialized view in another user's schema:
    You must have the CREATE ANY MATERIALIZED VIEW system privilege.
    The owner of the materialized view must have the CREATE TABLE system privilege. The owner must also have access to any master tables of the materialized view that the schema owner does not own (for example, if the master tables are on a remote database) and to any materialized view logs defined on those master tables, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a refresh-on-commit materialized view (ON COMMIT REFRESH clause), in addition to the preceding privileges, you must have the ON COMMIT REFRESH object privilege on any master tables that you do not own or you must have the ON COMMIT REFRESH system privilege.
    To create the materialized view with query rewrite enabled, in addition to the preceding privileges:
    If the schema owner does not own the master tables, then the schema owner must have the GLOBAL QUERY REWRITE privilege or the QUERY REWRITE object privilege on each table outside the schema.
    If you are defining the materialized view on a prebuilt container (ON PREBUILT TABLE clause), then you must have the SELECT privilege WITH GRANT OPTION on the container table.
    The user whose schema contains the materialized view must have sufficient quota in the target tablespace to store the master table and index of the materialized view or must have the UNLIMITED TABLESPACE system privilege.
    When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects.

  • Error while creating Materialized View in AWM

    Hello,
    I am using Oracle 11g with Analytic WorkSpace Manager 11.1.0.6.0A
    I am trying to create materialized view on my Cube..
    The Cube has 5 Dimensions out of which Four are having two levels i.e.,
    TotalA-->DimensionA
    TotalB-->DimensionB...and so on
    And one time Dimension having 4 levels
    TotalTime-->YEAR-->QUARTER-->MONTH
    When i try to create the materialized view, i get an error saying that
    "Your metadata changes have been saved, with the following errors
    CREATE MATERIALIZED VIEW "ENT.CB$TIME_TIME_HIER"
    ORA-02267:column type incompatible with referenced column type"
    When i googled regarding this error, it says to change the datatype of the column..
    But which column's data type is to be changed..Please throw some light regarding this...
    Awaiting for reply..

    My query is as follows:
    SELECT
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.level_name='ALL_MODE' AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_Type1Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.level_name='ALL_MODE' AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Type2Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LONG_DESCRIPTION='product1'AND l.level_name='ALL_MODE'AND m.LONG_DESCRIPTION = 'Type1' )then 1 else 0 end)) as Cumm_product1_Type1Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LONG_DESCRIPTION='product1'AND l.level_name='ALL_MODE'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_product1_Type2Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode1'AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_Mode1_Type1Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode1'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Mode1_Type2Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode2'AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_CLRING_Type1Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode2'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Mode2_Type2Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode3'AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_TRSFER_Type1Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode3'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Mode3_Type2Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.level_name='ALL_MODE' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.long_description='Mode3' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_Mode3_Txn_Amount,
    sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.long_description='Mode2' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_Mode2_Txn_Amount,
    sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.level_name='ALL_MODE' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_product1_Txn_Amount,
    sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.long_description='Mode1' AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_product1Mode1Type1_Txn_Amount,
    sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.long_description='Mode1' AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_product1_Mode1_Type2_Txn_Amount,
    sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.long_description='Mode1' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_product1_Mode1_Total_Txn_Amount
    /* From dimension views and cube view */
    FROM CUSTOMER_ID_CUSTOMER_ID_HIE_VIEW b,
    TIME_TIME_HIER_VIEW j,
    product_product_HIER_VIEW k,
    MODE_MODE_HIER_VIEW l,
    TYPE_TYPE_HIER_VIEW m,
    CUBETEST_VIEW cd
    /* Create level filters */
    WHERE b.level_name = 'CUSTOMER_ID'
    AND b.LONG_DESCRIPTION='xyz'
    AND j.LEVEL_NAME='MONTH'
    AND j.END_DATE between to_date('2007-10-31','YYYY-MM-DD') and to_date('2007-10-31','YYYY-MM-DD')
    /* Join dimension views to cube view */
    AND b.DIM_KEY=cd.ACCOUNT_ID
    AND j.DIM_KEY=cd.TIME
    AND k.DIM_KEY=cd.product
    AND l.DIM_KEY=cd.MODE
    AND m.DIM_KEY=cd.TYPE
    ORDER BY j.end_date,
    k.level_name,
    l.level_name,
    m.level_name;

  • Create materialized view throws insufficient privileges in single schema

    I'm trying to create a complex materialized view in my own schema, using only tables from my own schema:
    CREATE MATERIALIZED VIEW MYSCHEMA.MYMVIEW AS
        SELECT
            A.ONE_THING,
            B.ANOTHER_THING,
            C.A_THIRD_THING
        FROM MYSCHEMA.TABLEA A
        JOIN MYSCHEMA.TABLEB B
            ON A.COL1 = B.COL1
        JOIN MYSCHEMA.TABLEC C
            ON A.COL2 = C.COL2The line JOIN MYSCHEMA.TABLEB B throws an ORA-01031: insufficient privileges error, highlighting TABLEB.
    I understand that grants need to be explicit on tables when creating objects across schemas, but this code is operating within my own schema only; i created and own all the tables in this schema.
    What's going on?
    Thanks!

    Perhaps it is the tool that i am using that highlights the wrong item, because as it turns out, i don't have the CREATE MATERIALIZED VIEW permission after all (the permission was mistakenly granted to a different user instead of to me).
    SELECT * FROM SESSION_PRIVS;returns CREATE VIEW, but does not return CREATE MATERIALIZED VIEW.
    Sorry to have wasted your time.

  • Create materialized view, ORA-00942

    I would like to create a materialized view on user scott@orcl for user colinsuper. User scott@orcl have
    "CREATE ANY MATERIALIZED VIEW" permissions. Why does I get an ORA-00942 error?
    Remote-Database: remote_orcl.world
    Remote-Database-User: lindasuper
    Remote-Database-Table: cars
    scott@orcl>create synonym cars for lindasuper.cars@remote_orcl.world
    2 /
    Synonym created.
    scott@orcl>select car_no cno, car_bez cbez from cars
      2  where rownum <= 1;
    cno   cbez
    3     32-mxl
    scott@orcl
    scott@orcl
    scott@orcl>CREATE MATERIALIZED VIEW colinsuper.CARS_MV
      2    TABLESPACE my_tablespace
      3    BUILD IMMEDIATE
      4    USING INDEX TABLESPACE my_idx
      5    REFRESH
      6       START WITH sysdate
      7       NEXT ROUND(SYSDATE)+5/24 
      8       WITH PRIMARY KEY
      9    ENABLE QUERY REWRITE
    10    AS
    11    SELECT car_no cno
    12           car_bez cbez
    13    FROM cars
    14  /
    CREATE MATERIALIZED VIEW colinsuper.CARS_MV
    FEHLER in Zeile 1:
    ORA-00942: Tabelle or View does not exist
    scott@orcl>
    scott@orcl>
    scott@orcl>When I am creating the materialized view without the user colinsuper, materialized view
    is creating without problems.
    scott@orcl>CREATE MATERIALIZED VIEW CARS_MV
      2    TABLESPACE my_tablespace
      3    BUILD IMMEDIATE
      4    USING INDEX TABLESPACE my_idx
      5    REFRESH
      6       START WITH sysdate
      7       NEXT ROUND(SYSDATE)+5/24 
      8       WITH PRIMARY KEY
      9    ENABLE QUERY REWRITE
    10    AS
    11    SELECT car_no cno
    12           car_bez cbez
    13    FROM cars
    14  /
    Materialized View wurde erstellt.
    scott@orcl>
    scott@orcl>I think there is somthing wrong with the permissions of colinsuper!?

    Is this colinsuper a user in the remote database.
    ORA-00942:     table or view does not exist
    Cause:     
    The table or view entered does not exist, a synonym that is not allowed here was used, or a view was referenced where a table is required. Existing user tables and views can be listed by querying the data dictionary. Certain privileges may be required to access the table. If an application returned this message, the table the application tried to access does not exist in the database, or the application does not have access to it.
    Action:     
    Check each of the following:
    the spelling of the table or view name.
    that a view is not specified where a table is required.
    that an existing table or view name exists.
    Contact the database administrator if the table needs to be created or if user or application privileges are required to access the table.
    Also, if attempting to access a table or view in another schema, make certain the correct schema is referenced and that access to the object is granted.

  • Create Materialized View  based on another database table using db link?

    SQL> SELECT sysdate
    2 FROM dual@CBRLINK ;
    SYSDATE
    21-NOV-12
    SQL> CREATE MATERIALIZED VIEW USERCBR.V_T24_COUNTRY1
    2 REFRESH COMPLETE
    3 START WITH SYSDATE NEXT SYSDATE + (5/24)
    4 AS
    5 SELECT sysdate
    6 FROM dual@CBRLINK ;
    CREATE MATERIALIZED VIEW USERCBR.V_T24_COUNTRY1
    ERROR at line 1:
    ORA-04052: error occurred when looking up remote object SYS.DUAL@CBRLINK
    ORA-00600: internal error code, arguments: [ORA-00600: internal error code,
    arguments: [qksfroFXTStatsLoc() - unknown KQFOPT type!], [0], [], [], [], [],
    ORA-02063: preceding line from CBRLINK

    It works for me:orcl>
    orcl> CREATE MATERIALIZED VIEW scott.V_T24_COUNTRY1
      2  REFRESH COMPLETE
      3  START WITH SYSDATE NEXT SYSDATE + (5/24)
      4  AS
      5  SELECT sysdate
      6  FROM dual@l1 ;
    Materialized view created.
    orcl> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for 32-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    orcl>so there is no problem with the code. HTH.

  • ORA-04052 creating Materialized View

    ORA-04052 creating Materialized View
    Hi All !!
    I'm trying to create a Materialized view and his query definition uses an active public database link. When I ran the script for creating the view I get the following message:
    ERROR in line 1:
    ORA-04052: error occurred when looking up remote object
    USER.TABLE@ORCL2
    ORA-00604: error occurred at recursive SQL level 1
    ORA-03106: fatal two-task communication protocol error
    ORA-02063: preceding line from ORCL2
    But when I execute his definition query all is ok, the query works fine.
    I mean, I'm using the following sentence to create the view:
    CREATE MATERIALIZED VIEW my_view TABLESPACE tbsname BUILD IMMEDIATE
    REFRESH FORCE
    WITH ROWID
    ENABLE QUERY REWRITE
    AS
    SELECT ...
    FROM SCHEMA_NAME.TABLE_NAME@ORCL2;
    The above sentence give me ORA-04052. Nevertheless the SELECT... FROM SCHEMA_NAME.TABLE_NAME@ORCL2; works fine...
    I checked for the GLOBAL_NAMES parameter and it is set to FALSE. Please help me, How can I fix this problem ?
    I'm using Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production running over Win XP for create the view.
    The Database Link points to Oracle Database 10g Release 10.1.0.4.0 - 64bit Production running over Solaris
    Thanks in advance !!

    I've checked the NLS_LANG settings in both servers, and are set to AMERICAN. NLS TERRITORY are set to America also.

  • Error creating Materialized Views

    We are trying to create a materialized view between Oracle instances, one running 10.1.0.4 on Solaris, and one running 10.1.0.2 on Windows 2000 Svr.
    A link was established, and we can run select statements
    select count(*) from accounts@capsprd1
    however we get an error when trying to create the materialized view. See the following.
    SQL> create materialized view ACCOUNTS
    2 tablespace capstrac2
    3 nocache
    4 logging
    5 noparallel
    6 build immediate
    7 refresh complete
    8 NEXT TRUNC(SYSDATE) + 1 + 6/24
    9 AS
    10 SELECT * FROM ACCOUNTS@CAPSPRD1
    11 /
    create materialized view ACCOUNTS
    ERROR at line 1:
    ORA-04052: error occurred when looking up remote object
    [email protected]
    ORA-00604: error occurred at recursive SQL level 1
    ORA-03106: fatal two-task communication protocol error
    ORA-02063: preceding line from CAPSPRD1
    Any help would be greatly appreciated.
    Thanks

    Thanks for the feedback.
    We are actually performing a complete refresh, not a fast refresh, so I did not think we needed to create MV logs on the master.
    I did grant Create Materialized View to the schema, however I still receive the same issue. One thing I noticed in the error is it is automatically appending .WORLD on to the remote database. A domain is not used on the remote side (Solaris), and I thought I had configured the 'data warehouse' side (Windows) to not use a domain.
    ORA-04052: error occurred when looking up remote object
    [email protected]
    Can anyone tell me why .WORLD is being appended?
    Thanks for the help.

Maybe you are looking for

  • Bug in radix-tree.c causes kernel panic

    Hi, I've got a server that has been running Arch Linux for couple of weeks without any major problems. Kernel version is 2.6.18. Unfortunately I can't get a dmesg from the server, as it's crashed at the moment... Today the server started having weird

  • How to email Adobe staff working in USA only-re website?

    I had no luck in adobe.com website CHAT in getting adequate answer due to person not understanding English well. I can't get a live person when call 800# as auto-robot-choices-asks about specific software choices then says to go to website, can't tal

  • Can't edit a tune

    I highlite the tune and go to get info and options and set the stoptime to a value like 2:00 and then it does stop when I play it from iTunes but when I put that tune in a DVD or Slideshow it reverts to the full length. How can you edit a tune to fit

  • How to turn off an application in iOS 4.0

    When running an application, hittin the Home button once wont close the app - the appwill continue to run in the background. The only way (that I know of) how to actually turn off an app is to hit the Home buton twice (enter the multitasking screen),

  • The sound delays when it in my compressor 1.2.1, somebody can help me

    I tried the same problems that you people, now that I was to think that the problems had finished, is when I discover another one. In the DVD Studio Pro when I make preview, I repair that the sound is delayed, not in the begining of the film but in t