oracle oracle如何刷新物化视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11554886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:20:29  来源:igfitidea点击:

How to refresh materialized view in oracle

oraclematerialized-views

提问by Srinivas

Iam trying to refresh the materialized view by using:

我正在尝试使用以下方法刷新物化视图:

DBMS_MVIEW.REFRESH('v_materialized_foo_tbl')

But it's throwing invalid sql statement.

但它抛出了无效的 sql 语句。

Then I have created a stored procedure like this:

然后我创建了一个这样的存储过程:

CREATE OR REPLACE 
PROCEDURE MAT_VIEW_FOO_TBL 
IS
BEGIN
   DBMS_MVIEW.REFRESH('v_materialized_foo_tbl')
END MAT_VIEW_FOO_TBL IS;

This procedure has been created successfully but when i am calling this procedure with

此过程已成功创建,但是当我调用此过程时

MAT_VIEW_FOO_TBL;

it's throwing an error again.

它再次抛出错误。

Kindly suggest a solution for this issue.

请为这个问题提出一个解决方案。

Thanks, Srinivas

谢谢,斯里尼瓦斯

采纳答案by fahim ashraf

try this:

尝试这个:

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

firstparameter is name of mat_viewand seconddefines type of refresh. fdenotes fast refresh. but keep this thing in mind it will overrideany any other refresh timing options.

第一参数是的名称mat_view第二定义键入refreshf表示快速刷新。但请记住这一点,它会覆盖任何其他刷新时间选项。

回答by Waqas Ali

Run this script to refresh data in materialized view:

运行此脚本以刷新物化视图中的数据:

BEGIN
DBMS_SNAPSHOT.REFRESH('Name here');
END;

回答by Sonic Soul

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)

游戏有点晚了,但我找到了一种方法来使这个问题中的原始语法起作用(我在 Oracle 11g 上)

** first switch to schema of your MV **

** 首先切换到你的 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.

这实际上对我有用,并且添加并行选项使我的执行速度提高了大约 2.5 倍。

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

更多信息:如何并行刷新物化视图

回答by Yasir Meraj

You can refresh a materialized view completely as follows:

您可以按如下方式完全刷新物化视图:

EXECUTE  
DBMS_SNAPSHOT.REFRESH('Materialized_VIEW_OWNER_NAME.Materialized_VIEW_NAME','COMPLETE');

回答by mike

Best option is to use the '?' argument for the method. This way DBMS_MVIEW will choose the best way to refresh, so it'll do the fastest refresh it can for you. , and won't fail if you try something like method=>'f' when you actually need a complete refresh. :-)

最好的选择是使用“?” 方法的论据。这样 DBMS_MVIEW 将选择最佳刷新方式,因此它会为您进行最快的刷新。,并且如果您在实际需要完全刷新时尝试诸如 method=>'f' 之类的东西,则不会失败。:-)

from the SQL*Plus prompt:

从 SQL*Plus 提示符:

EXEC DBMS_MVIEW.REFRESH('my_schema.my_mview', method => '?');

回答by Will Lovett

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.

如果您使用 SQL Developer,则必须将 dbms_view 设为小写。其余的对我来说编译得很好,尽管我还没有从代码中调用该过程。

CREATE OR REPLACE PROCEDURE "MAT_VIEW_FOO_TBL" AS 
BEGIN
  dbms_mview.refresh('v_materialized_foo_tbl');
END;

回答by Vikash Prasad

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.

希望以上有帮助。

回答by issam

EXECUTE dbms_mview.refresh('view name','cf');

执行 dbms_mview.refresh('视图名称','cf');

回答by moses

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

当我们必须使用内置程序或包时,我们必须使用“EXECUTE”命令,然后它就会起作用。

EX:

前任:

EXECUTE exec DBMS_MVIEW.REFRESH('v_materialized_foo_tbl');

EXECUTE exec DBMS_MVIEW.REFRESH('v_materialized_foo_tbl');