select * from (select * from tablename order by dbms_random.value) where rownum < N;
例:
select * from (select * from tablename order by dbms_random.value) where rownum < 3;
注:dbms_random包需要手工安装,位于$ORACLE_HOME/rdbms/admin/dbmsrand.sql
dbms_random.value(100,200)可以产生100到200范围的随机数
按概率抽取:
select * from tablename sample(百分比);
例:
select * from tablename sample(10);