【问题标题】:Add column to materialized view将列添加到物化视图
【发布时间】:2015-09-09 12:33:45
【问题描述】:

我在 Oracle 中有一个现有的物化视图。 但我想为其添加更多列。我看到无法执行 CREATE OR REPLACE 到物化视图,我该怎么做呢?

谢谢!

【问题讨论】:

  • drop materialized view ..; create materialized view ...
  • 但是如果我做一个'DROP'并且物化视图不存在,数据库会给我一个错误,对吧?

标签: oracle materialized-views


【解决方案1】:

将列添加到基表中,然后在 MV 中运行刷新。

declare
begin
  DBMS_SNAPSHOT.REFRESH('your_mv', 'f');
end;

【讨论】:

    【解决方案2】:
    select * from dba_objects where status='INVALID';
    
    grant create materialized view to <schema>;
    grant create table to <schema>;
    
    drop MATERIALIZED VIEW <schema>.<mvname>;
    
      CREATE MATERIALIZED VIEW <schema>.<mvname>
      (...)
      AS SELECT (...);
    
    select * from  <schema>.<mvname>;
    
    
    revoke create materialized view from <schema>;
    revoke create table from <schema>;
    
    select * from dba_objects where status='INVALID';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-27
      • 2020-11-27
      • 2014-12-19
      • 2021-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多