SQL语句如下:
SELECT 'Red Ball#' || ROWNUM AS RED_BALL, Val
FROM (
SELECT trunc(dbms_random.value(1, 34)) AS Val
from dual
connect by level <= 6
ORDER BY Val
)
UNION ALL
SELECT 'Blue Ball', trunc(dbms_random.value(1, 17))
FROM dual;
结果示例如下:
1 Red Ball#1 2
2 Red Ball#2 5
3 Red Ball#3 16
4 Red Ball#4 18
5 Red Ball#5 22
6 Red Ball#6 27
7 Blue Ball 10
存在问题:
有时候会有重复数据,:—