select *
from (select rownum, c.empno, c.ename, c.job
from (select * from scott.emp order by dbms_random.value) c
where rownum <= 6);随机获取前六条
本文介绍了一种使用PL/SQL在Oracle数据库中随机选取特定数量记录的方法。通过利用DBMS_RANDOM函数为每条记录生成随机数,并按此进行排序,可以有效地实现数据的随机选取。
select *
from (select rownum, c.empno, c.ename, c.job
from (select * from scott.emp order by dbms_random.value) c
where rownum <= 6);
被折叠的 条评论
为什么被折叠?