无法使用表格中物化视图日志中的过滤列

时间:2018-02-15 18:18:30

标签: sql database oracle

我正在尝试创建聚合物化视图:

for con_id in con_ids:
    for news_id in range(2,10):
        print(news_id)
        print("(//div[@id='"+con_id+"']/table/tbody/tr)["+str(news_id)+"]")
        headline = driver.find_element_by_xpath("(//div[@id='"+con_id+"']/table/tbody/tr)["+str(news_id)+"]")
        value = headline.find_element_by_xpath(".//td[2]/a")
        print(value.get_attribute("innerText").encode('utf-8'))

我不明白这个错误。我为LLATTRDATA时间和DTREECORE表创建了一个MV日志文件

CREATE MATERIALIZED VIEW MV_LLATTRDATA_MAX_VERSIONS
    NOLOGGING
    BUILD IMMEDIATE 
    REFRESH FAST ON COMMIT
    ENABLE QUERY REWRITE
    AS 
        SELECT AD.DEFID, AD.ATTRID, MAX(AD.VERNUM) AS MAX_VERNUM, MIN(AD.DEFVERN) AS MAX_DEFVERN
        FROM   CSTST.MV_LLATTRDATA_PARTITIONED_TEST AD, DTREECORE DT
        WHERE AD.ID = DT.DATAID
        GROUP BY AD.DEFID, AD.ATTRID;

错误:

  

错误报告 - ORA-12033:无法使用物化的过滤列   查看登录“CSTST”。“DTREECORE”   12033. 0000 - “无法使用物化视图中的过滤列登录\”%s \“。\”%s \“”

     

原因:物化视图日志中没有过滤列              记录,或与筛选器列关联的时间戳              比上次更新时间更新。

     

操作:在下次快速刷新之前需要完全刷新。              如果需要,将过滤器列添加到物化视图日志中。

DTREECORE DDL:

CREATE MATERIALIZED VIEW LOG ON CSTST.DTREECORE (and LLATTR) WITH ROWID INCLUDING NEW VALUES; 

LLATTRCORE DDL:

CREATE MATERIALIZED VIEW LOG ON "CSTST"."DTREECORE"
 PCTFREE 10 PCTUSED 30 INITRANS 1 MAXTRANS 255 LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "CSPRD" 
  WITH ROWID INCLUDING NEW VALUES;

我尝试添加LLATTRCORE查看日志以包含新值,但我遇到了权限问题

1 个答案:

答案 0 :(得分:2)

文档显示"Restrictions on Fast Refresh on Materialized Views with Aggregates"

  

物化视图中的所有表必须具有物化视图日志,物化视图日志必须:

     
      
  • 包含实体化视图中引用的表中的所有列。
  •   
  • 使用ROWID指定并包含新值。
  •   
  • 如果预计表格会混合插入/直接加载,删除和更新,请指定SEQUENCE子句。
  •   

您需要在日志中包含MV中使用的所有列,例如:

CREATE MATERIALIZED VIEW LOG ON MV_LLATTRDATA_PARTITIONED_TEST
WITH ROWID, SEQUENCE(ID, DEFID, ATTRID, VERNUM, DEFVERN) INCLUDING NEW VALUES;

CREATE MATERIALIZED VIEW LOG ON DTREECORE
WITH ROWID, SEQUENCE(DATAID) INCLUDING NEW VALUES;

然后你可以创建MV:

CREATE MATERIALIZED VIEW MV_LLATTRDATA_MAX_VERSIONS
    NOLOGGING
    BUILD IMMEDIATE 
    REFRESH FAST ON COMMIT
    ENABLE QUERY REWRITE
    AS 
        SELECT AD.DEFID, AD.ATTRID, MAX(AD.VERNUM) AS MAX_VERNUM, MIN(AD.DEFVERN) AS MAX_DEFVERN
        FROM   MV_LLATTRDATA_PARTITIONED_TEST AD, DTREECORE DT
        WHERE AD.ID = DT.DATAID
        GROUP BY AD.DEFID, AD.ATTRID;

Materialized view MV_LLATTRDATA_MAX_VERSIONS created.

不是最有用的错误消息......