将列添加到物化视图

时间:2015-06-23 15:41:59

标签: oracle materialized-views

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

谢谢!

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

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';