首页 \ 问答 \ 如何刷新oracle中的物化视图(How to refresh materialized view in oracle)

如何刷新oracle中的物化视图(How to refresh materialized view in oracle)

Iam尝试使用以下命令刷新物化视图:

DBMS_MVIEW.REFRESH('v_materialized_foo_tbl')

但它是抛出无效的SQL语句。

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

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

这个程序已经成功创建,但是当我用这个程序调用时

MAT_VIEW_FOO_TBL;

它再次抛出一个错误。

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

谢谢,Srinivas


Iam trying to refresh the materialized view by using:

DBMS_MVIEW.REFRESH('v_materialized_foo_tbl')

But it's throwing invalid sql statement.

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


原文:https://stackoverflow.com/questions/11554886
更新时间:2021-09-23 14:09

最满意答案

是的,你是对的,你正在寻找代数数据类型。 在Learn You a Haskell上有一个很棒的教程。

为了记录,来自OOP的抽象类的概念实际上有三种不同的翻译成Haskell,而ADT仅仅是一种。 这里简要介绍一下这些技术。

代数数据类型

代数数据类型对其子类已知的抽象类的模式进行编码,其中函数通过向下转换来检查对象是哪个特定实例。

abstract class IntBox { }

class Empty : IntBox { }

class Full : IntBox {
    int inside;
    Full(int inside) { this.inside = inside; }
}

int Get(IntBox a) {
    if (a is Empty) { return 0; }
    if (a is Full)  { return ((Full)a).inside; }
    error("IntBox not of expected type");
}

翻译成:

data IntBox = Empty | Full Int

get :: IntBox -> Int
get Empty = 0
get (Full x) = x

功能记录

这种风格不允许向下转换,所以上面的Get函数在这种风格中是不可表达的。 所以这里完全不同。

abstract class Animal { 
    abstract string CatchPhrase();
    virtual void Speak() { print(CatchPhrase()); }
}

class Cat : Animal {
    override string CatchPhrase() { return "Meow"; }
}

class Dog : Animal {
    override string CatchPhrase() { return "Woof"; }
    override void Speak() { print("Rowwrlrw"); }
}

它在Haskell中的翻译不会将类型映射到类型中。 Animal是唯一的类型, DogCat被挤压到它们的构造函数中:

data Animal = Animal {
    catchPhrase :: String,
    speak       :: IO ()
}

protoAnimal :: Animal
protoAnimal = Animal {
    speak = putStrLn (catchPhrase protoAnimal)
}

cat :: Animal
cat = protoAnimal { catchPhrase = "Meow" }

dog :: Animal
dog = protoAnimal { catchPhrase = "Woof", speak = putStrLn "Rowwrlrw" }

这个基本概念有几种不同的排列。 不变的是,抽象类型是记录类型,其中方法是记录的字段。

编辑:有关此方法的一些细微之处的评论中有一个很好的讨论,包括上述代码中的一个错误。

类型类

这是我最不喜欢的面向对象思想的编码。 OO程序员很舒服,因为它使用熟悉的单词和地图类型来表示类型。 但是当事情变得复杂时,以上函数的记录往往更容易处理。

我将再次编码Animal示例:

class Animal a where
    catchPhrase :: a -> String
    speak       :: a -> IO ()

    speak a = putStrLn (catchPhrase a)

data Cat = Cat 
instance Animal Cat where
    catchPhrase Cat = "Meow"

data Dog = Dog
instance Animal Dog where
    catchPhrase Dog = "Woof"
    speak Dog = putStrLn "Rowwrlrw"

这看起来不错,不是吗? 当你意识到即使它看起来像面向对象的时候,困难就出现了,它并不像面向对象那样工作。 你可能想要一个动物列表,但你现在可以做的最好的动物是Animal a => [a] ,同类动物列表,例如。 只有猫或只有狗的列表。 然后你需要使这个包装类型:

data AnyAnimal = forall a. Animal a => AnyAnimal a
instance Animal AnyAnimal where
    catchPhrase (AnyAnimal a) = catchPhrase a
    speak (AnyAnimal a) = speak a

然后[AnyAnimal]就是你想要的动物列表。 然而,事实证明, AnyAnimal在第二个例子中公开了关于它自己的与Animal记录完全相同的信息,我们刚刚以迂回的方式进行了讨论。 因此,为什么我不认为类型类是一个非常好的面向对象编码。

因此总结本周版本的方式太多信息!


Yes, you are correct, you are looking for algebraic data types. There is a great tutorial on them at Learn You a Haskell.

For the record, the concept of an abstract class from OOP actually has three different translations into Haskell, and ADTs are just one. Here is a quick overview of the techniques.

Algebraic Data Types

Algebraic data types encode the pattern of an abstract class whose subclasses are known, and where functions check which particular instance the object is a member of by down-casting.

abstract class IntBox { }

class Empty : IntBox { }

class Full : IntBox {
    int inside;
    Full(int inside) { this.inside = inside; }
}

int Get(IntBox a) {
    if (a is Empty) { return 0; }
    if (a is Full)  { return ((Full)a).inside; }
    error("IntBox not of expected type");
}

Translates into:

data IntBox = Empty | Full Int

get :: IntBox -> Int
get Empty = 0
get (Full x) = x

Record of functions

This style does not allow down-casting, so the Get function above would not be expressible in this style. So here is something completely different.

abstract class Animal { 
    abstract string CatchPhrase();
    virtual void Speak() { print(CatchPhrase()); }
}

class Cat : Animal {
    override string CatchPhrase() { return "Meow"; }
}

class Dog : Animal {
    override string CatchPhrase() { return "Woof"; }
    override void Speak() { print("Rowwrlrw"); }
}

Its translation in Haskell doesn't map types into types. Animal is the only type, and Dog and Cat are squashed away into their constructor functions:

data Animal = Animal {
    catchPhrase :: String,
    speak       :: IO ()
}

protoAnimal :: Animal
protoAnimal = Animal {
    speak = putStrLn (catchPhrase protoAnimal)
}

cat :: Animal
cat = protoAnimal { catchPhrase = "Meow" }

dog :: Animal
dog = protoAnimal { catchPhrase = "Woof", speak = putStrLn "Rowwrlrw" }

There are a few different permutations of this basic concept. The invariant is that the abstract type is a record type where the methods are the fields of the record.

EDIT: There is a good discussion in the comments on some of the subtleties of this approach, including a bug in the above code.

Typeclasses

This is my least favorite encoding of OO ideas. It is comfortable to OO programmers because it uses familiar words and maps types to types. But the record of functions approach above tends to be easier to work with when things get complicated.

I'll encode the Animal example again:

class Animal a where
    catchPhrase :: a -> String
    speak       :: a -> IO ()

    speak a = putStrLn (catchPhrase a)

data Cat = Cat 
instance Animal Cat where
    catchPhrase Cat = "Meow"

data Dog = Dog
instance Animal Dog where
    catchPhrase Dog = "Woof"
    speak Dog = putStrLn "Rowwrlrw"

This looks nice, doesn't it? The difficulty comes when you realize that even though it looks like OO, it doesn't really work like OO. You might want to have a list of Animals, but the best you can do right now is Animal a => [a], a list of homogeneous animals, eg. a list of only Cats or only Dogs. Then you need to make this wrapper type:

{-# LANGUAGE ExistentialQuantification #-}

data AnyAnimal = forall a. Animal a => AnyAnimal a
instance Animal AnyAnimal where
    catchPhrase (AnyAnimal a) = catchPhrase a
    speak (AnyAnimal a) = speak a

And then [AnyAnimal] is what you want for your list of animals. However, it turns out that AnyAnimal exposes exactly the same information about itself as the Animal record in the second example, we've just gone about it in a roundabout way. Thus why I don't consider typeclasses to be a very good encoding of OO.

And thus concludes this week's edition of Way Too Much Information!

相关问答

更多
  • 是的,你是对的,你正在寻找代数数据类型。 在Learn You a Haskell上有一个很棒的教程。 为了记录,来自OOP的抽象类的概念实际上有三种不同的翻译成Haskell,而ADT仅仅是一种。 这里简要介绍一下这些技术。 代数数据类型 代数数据类型对其子类已知的抽象类的模式进行编码,其中函数通过向下转换来检查对象是哪个特定实例。 abstract class IntBox { } class Empty : IntBox { } class Full : IntBox { int insi ...
  • 如果查看decode_encode的推断类型 :t decode_encode > decode_encode :: ((BTAlg BT -> (BTAlg z -> z) -> z) -> t) -> t 很明显,GHC已经失去了相当多的多态性。 我不完全确定这里的细节 - 这段代码需要ImpredicativeTypes来编译,这通常是我理解开始崩溃的地方。 但是,有一种保持多态性的标准方法:使用newtype newtype BT = BT { runBT :: forall z. (BTAlg ...
  • ADT封闭的事实使写入总功能变得更加容易。 这是总是产生结果的函数,对于其类型的所有可能的值,例如。 maybeToList :: Maybe a -> [a] maybeToList Nothing = [] maybeToList (Just x) = [x] 如果Maybe是开放的,有人可以添加一个额外的构造函数,并且maybeToList函数会突然断开。 在OO中,这不是一个问题,当您使用继承来扩展类型时,因为当您调用一个没有特定重载的函数时,它只能使用超类的实现。 也就是说,如果Student ...
  • 使其编译所需的最小变化是简单地为非空列表的模式添加一些括号; 例如 hlistToLinkedList (x:xs) = ... 通过要求括号表示复杂模式,编译器不需要知道每个构造函数需要多少个参数; 降低上下文敏感性和促进单独编译的重要技巧。 The minimal change needed to make it compile is to simply add some parentheses to the patterns for non-empty lists; e.g. hlistToLink ...
  • 在回答之前,我应该指出,你可能会陷入普通初学者对ADT的误解。 请记住,Haskell有两个单独的名称空间用于类型和术语级别。 所以,如果我们写: data A = Foo data B = Bar data C = Baz data D = A | B | C ...那么类型A和类型D的构造函数A之间没有任何联系。 因此,我怀疑(但我不完全确定!)您要问的问题类型D格式如下: data D = A A | B B | C C 在这种情况下,简短的回答是“不”。 您可能希望您可以使用deriving D ...
  • 你刚发明了类型类! 一个类是一个函数字典。 编译期间,代码如 class Monoid a where mempty :: a mappend :: a -> a -> a instance Monoid [a] where mempty = [] mappend = (++) mconcat :: Monoid a => [a] -> a mconcat = foldr mappend main = print $ mconcat ["foo", "bar"] 被翻 ...
  • 你似乎想为多项式做一个ADT,但我更喜欢使用Map。 首先一些进口: import qualified Data.Map as M import Data.Function (on) 多项式是从x的幂到系数的映射。 newtype Poly a n = Poly {coeffMap :: M.Map n a} deriving (Show) lift f = Poly . f . coeffMap 我们来做一些简单的多项式: zero = Poly M.empty -- ...
  • 你可以大致模仿它 record StageInitial, data : String record StageFinished, data : String alias Stage = StageInitial | StageFinished 然后与case进行模式匹配。 然而,这并不是一种特殊的惯用方式,所以你可能会在稍后遇到摩擦。 You can roughly emulate it with record StageInitial, data : String record StageFinish ...
  • 抽象数据类型不会导出其实现,而是更倾向于导出可用于构建和使用它们的函数。 containers包中有许多奇妙且经常使用的例子; 作为具有非常丰富的API的类型,我们立即想到了Map类型,但是不允许您查看实现细节。 Set , Seq和专门的IntMap和IntSet类型都是抽象的。 所有Haskell类型都是代数 - 这只意味着它们都是由求和,乘积,函数类型和递归构成的。 Abstract data types do not export their implementation, instead pref ...
  • 首先,你想要做什么来限制a到Num并不需要像GADT那样复杂的东西。 如果您的类型为Expression a和函数exprFunc ,则可以按如下方式声明它。 exprFunc :: Num a => Expression a -> Expression a 有了这个, exprFunc将只包含Num s的参数。 至于你的第二个问题,在Haskell中做多态函数的唯一(接受)方法是通过类型类。 因此,对于使用Integral和Fractional示例,最好的方法是执行以下操作。 class Num a = ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)