Oracle 生成随机数,随机字符串

               

1. 随机数包

SELECT DBMS_RANDOM.VALUE
  FROM DUAL;
2. 在[0..100]范围内取随机数

SELECT TRUNC (DBMS_RANDOM.VALUE (0, 100))
  FROM DUAL;
3. 大于字符‘A’的10个字符随机字符串

SELECT DBMS_RANDOM.STRING ('A', 10)
  FROM DUAL;
4. 单个小写随机字符

SELECT CHR (ROUND (DBMS_RANDOM.VALUE (97, 122)))
  FROM DUAL;
5. 在过去10天内取随机日期

SELECT TO_DATE (TRUNC (DBMS_RANDOM.VALUE (TO_NUMBER (TO_CHAR (SYSDATE - 10,
                                                              'J'
                                                             )
                                                    ),
                                          TO_NUMBER (TO_CHAR (SYSDATE, 'J'))
                                         )
                      ),
                'J'
               )
  FROM DUAL;
6. 在过去30分钟内取随机时间

SELECT (SYSDATE - 1 / 24 / 60 * 30) + DBMS_RANDOM.VALUE (1, 1800) / 3600 / 24
  FROM DUAL;

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wl076/archive/2007/08/08/1731740.aspx

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

你可能感兴趣的:(Oracle 生成随机数,随机字符串)