Home > Database > Mysql Tutorial > body text

Oracle中的DETERMINISTIC

WBOY
Release: 2016-06-07 16:43:26
Original
2116 people have browsed it

多次看到DETERMINISTIC,一直很疑惑,今天做了一个实验。我们欺骗ORACLE说是一个DETERMINISTIC函数,它在SQL中只调用一次。如果不

多次看到DETERMINISTIC,一直很疑惑,,今天做了一个实验。我们欺骗Oracle说是一个DETERMINISTIC函数,它在SQL中只调用一次。如果不使用DETERMINISTIC,可以看到出来的值都不一样。使用DETERMINISTIC后,不同的会话都出来一样的值。
 
SQL> create or replace function f_t(i_p int) return number DETERMINISTIC is
      i_rtn number;
    begin
      i_rtn := i_p * dbms_random.value(1,10);
      return i_rtn;
    end;
    /
 函数已创建。
 
session1:
 SQL> select LEVEL,f_t(1) FROM DUAL CONNECT BY LEVEL      LEVEL    F_T(1)
 ---------- ----------
          1 2.55732959
          2 2.55732959
          3 2.55732959
          4 2.55732959
          5 2.55732959
          6 2.55732959
          7 2.55732959
          8 2.55732959
          9 2.55732959
        10 2.55732959
 已选择10行。
 

 

session2:
 SQL> select LEVEL,f_t(1) FROM DUAL CONNECT BY LEVEL      LEVEL    F_T(1)
 ---------- ----------
          1 2.55732959
          2 2.55732959
          3 2.55732959
          4 2.55732959
          5 2.55732959
          6 2.55732959
          7 2.55732959
          8 2.55732959
          9 2.55732959
        10 2.55732959
 已选择10行。
 

SQL> create or replace function f_t(i_p int) return number is
        i_rtn number;
    begin
        i_rtn := i_p * dbms_random.value(1,10);
        return i_rtn;
    end;
    /
 函数已创建。
 

SQL> select LEVEL,f_t(1) FROM DUAL CONNECT BY LEVEL      LEVEL    F_T(1)
 ---------- ----------
          1 8.48649118
          2  8.9396978
          3  2.2786135
          4 5.29205905
          5 5.32847713
          6 8.70095819
          7 6.20471031
          8 2.00101537
          9 3.53814265
        10 3.64991086
 已选择10行。

Oracle 11g 在RedHat Linux 5.8_x64平台的安装手册

Linux-6-64下安装Oracle 12C笔记

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2

本文永久更新链接地址:

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!