遇到我太早了,我还不是高手呢。
你的问题很有趣,我特地翻了下书,没有看到有随机数的产生方法。
不过我觉得可以这样考虑:
用当前时间的最后几位(毫秒级)作为随机数,或者用于产生随机数,比如09:03:56.123,这里的123作为随机数或者产生随机数:nnn/10可以产生0-99的随机数,类似的可以产生1000以下任意范围的随机数。
希望这个思路对你有用。

解决方案 »

  1.   

    The first version of VALUE returns a random number that is greater than or equal to 0 and less than 1. The second version of VALUE returns a random number that is greater than or equal to LOW and less than HIGH. Here is an example of their usage: SQL> select dbms_random.value, 
    dbms_random.value(55,100)
      2  from dual;   VALUE   DBMS_RANDOM.VALUE(55,100)
    ---------------   -----------------------------
         .782821936   79.6367038

    dbms_random(value);
      

  2.   

    select top n * from yourtable order by newid()
      

  3.   

    select dbms_random.value(55,100) from dual
    怎么不能执行啊?
    报错:dbms_random.无效列名
      

  4.   

    select dbms_random.value(55,100) from dual
    可以
    我用的是9I
      

  5.   

    8i中dbms_random包需要另外装的,但忘了是那个文件了
    :(
      

  6.   

    Using Oracle Supplied Packages
    Most Oracle supplied packaged are automatically installed when the database is created and the CATPROC.SQL script is run. For example, to create the DBMS_ALERT package, the DBMSALRT.SQL and PRVTALRT.PLB scripts must be run when connected as the user SYS. These scripts, however, are run automatically by the CATPROC.SQL script. Certain packages are not installed automatically. Special installation instructions for these packages are documented in the individual chapters. To call a PL/SQL function from SQL, you must either own the function or have EXECUTE privileges on the function. To select from a view defined with a PL/SQL function, you must have SELECT privileges on the view. No separate EXECUTE privileges are needed to select from the view. Instructions on special requirements for packages are documented in the individual chapters. TMD,Oracle网站也没介绍怎么安装附加包啊
      

  7.   

    如果没有安装包,执行这个文件:
    $ORACLE_HOME/RDBMS/ADMIN/dbmsrand.sql;
    用sys用户在sqlplus下运行这个文件就可以了select * from 
    (select * from xxx order by  dbms_random.value)
    where rownum < n+1;
    对于8i,还可以这么做select * from 
    (select * from xxx order by sys_guid())
    where rownum < n+1;btw:
    不是怪哪里介绍不介绍的
    这些都是基本常识
    只是这里的做开发的人太多,了解oracle的人太少
      

  8.   

    当然,大家还可以参考 sample  函数
      

  9.   

    如果是MySQL,可以用
    select * from table order by rand() limit n;
    不过有性能问题
      

  10.   

    biti_rainy(biti_rainy)要是常来这里就好了,高手!
    先置顶,大家看看。
      

  11.   

    随机数就用这个包就行了dbms_random