How to refresh materialized view in oracle

前端 未结 9 1461
小鲜肉
小鲜肉 2020-12-13 03:46

Iam trying to refresh the materialized view by using:

DBMS_MVIEW.REFRESH(\'v_materialized_foo_tbl\')

But it\'s throwing invalid sql stateme

相关标签:
9条回答
  • 2020-12-13 04:01

    When we have to use inbuilt procedures or packages we have to use "EXECUTE" command then it will work.

    EX:

    EXECUTE exec DBMS_MVIEW.REFRESH('v_materialized_foo_tbl');

    0 讨论(0)
  • 2020-12-13 04:02

    try this:

    DBMS_SNAPSHOT.REFRESH( 'v_materialized_foo_tbl','f'); 
    

    first parameter is name of mat_view and second defines type of refresh. f denotes fast refresh. but keep this thing in mind it will override any any other refresh timing options.

    0 讨论(0)
  • 2020-12-13 04:02

    You can refresh a materialized view completely as follows:

    EXECUTE  
    DBMS_SNAPSHOT.REFRESH('Materialized_VIEW_OWNER_NAME.Materialized_VIEW_NAME','COMPLETE');
    
    0 讨论(0)
  • 2020-12-13 04:03

    If you're working with SQL Developer, you have to put the dbms_view in lowercase. The rest compiled fine for me although I haven't called the procedure from code yet.

    CREATE OR REPLACE PROCEDURE "MAT_VIEW_FOO_TBL" AS 
    BEGIN
      dbms_mview.refresh('v_materialized_foo_tbl');
    END;
    
    0 讨论(0)
  • 2020-12-13 04:08

    Try using the below syntax:

    Common Syntax:

    begin
    dbms_mview.refresh('mview_name');
    end;
    

    Example:

    begin
    dbms_mview.refresh('inv_trans');
    end;
    

    Hope the above helps.

    0 讨论(0)
  • 2020-12-13 04:10

    a bit late to the game, but I found a way to make the original syntax in this question work (I'm on Oracle 11g)

    ** first switch to schema of your MV **

    EXECUTE DBMS_MVIEW.REFRESH(LIST=>'MV_MY_VIEW');
    

    alternatively you can add some options:

    EXECUTE DBMS_MVIEW.REFRESH(LIST=>'MV_MY_VIEW',PARALLELISM=>4);
    

    this actually works for me, and adding parallelism option sped my execution about 2.5 times.

    More info here: How to Refresh a Materialized View in Parallel

    0 讨论(0)
提交回复
热议问题