0

我想在创建物化视图时将数据插入表后自动刷新物化视图。

我尝试了以下代码(从创建每 5 分钟刷新一次的物化视图开始)但无法正常工作。此代码也是每 1 分钟刷新一次的解决方案。

插入数据时我想要一个解决方案。可能吗?

Create Materialized view temp_mv refresh complete start with (sysdate) next (sysdate+1/1440) with rowid as select * from temp;

4

1 回答 1

1

你可以试试这个,但它不适用于更复杂的视图。

  --create table
    create table temp (a int not null primary key);


    -- create table log; 
    create materialized view log on temp
    with primary key
    including new values;

    --create view 
    create materialized view temp_mv
    build immediate 
    refresh fast
    on commit
    as
    select * from temp;


    -- populate table 
    insert into  temp select level from dual connect by level <100;

    select * from temp_mv; -- no value 

    commit; -- view is refreshed


    select * from temp_mv; -- all values
于 2019-01-08T12:03:39.633 回答