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;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17066567/viewspace-664201/,如需转载,请注明出处,否则将追究法律责任。