ITPub博客

首页 > 数据库 > Oracle > oracle deterministic关键字.

oracle deterministic关键字.

原创 Oracle 作者:jidongzheng 时间:2009-03-23 13:05:31 0 删除 编辑

在看thomas kyte 的<>时,

发现在它的书就提到的一个关键字.deterministic

DETERMINISTIC Clause

Specify DETERMINISTIC to indicate that the function returns the same result value whenever it is called with the same values for its arguments.

You must specify this keyword if you intend to call the function in the expression of a function-based index or from the query of a materialized view that is marked REFRESH FAST or ENABLE QUERY REWRITE. When Oracle Database encounters a deterministic function in one of these contexts, it attempts to use previously calculated results when possible rather than reexecuting the function. If you subsequently change the semantics of the function, you must manually rebuild all dependent function-based indexes and materialized views.

Do not specify this clause to define a function that uses package variables or that accesses the database in any way that might affect the return result of the function. The results of doing so will not be captured if Oracle Database chooses not to reexecute the function.

The following semantic rules govern the use of the DETERMINISTIC clause:

  • You can declare a top-level subprogram DETERMINISTIC.

  • You can declare a package-level subprogram DETERMINISTIC in the package specification but not in the package body.

  • You cannot declare DETERMINISTIC a private subprogram (declared inside another subprogram or inside a package body).

  • A DETERMINISTIC subprogram can call another subprogram whether the called program is declared DETERMINISTIC or not.

[@more@]

看了下oracle的官方文档,这个关键字表明:如果你的函数当输入一样时,会返回同样的结果.

这样, 数据库就用前一个计算的值,而不需要再重新计算一次.

这对于使用函数索引等,会直到相当大的好处.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/197458/viewspace-1019311/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: oracle reverse函数
请登录后发表评论 登录
全部评论
  • 博文量
    152
  • 访问量
    724085