教你轻松掌握随机抽取记录的方法
2007-09-14 12:40:27 来源:WEB开发网核心提示:问:能否给我介绍一种随机抽取记录的方法? 答:以下代码以抽取6条为例: create table t as select * fromall_objects where rownum <= 5000;set timing onselect object_name, object_idfrom ( select o
问:能否给我介绍一种随机抽取记录的方法?
答:以下代码以抽取6条为例:
create table t as select * from
all_objects where rownum <= 5000;
set timing on
select object_name, object_id
from ( select object_name, object_id
from t
where object_name like '%%'
order by dbms_random.random )
where rownum <= 6;
select object_name, object_id
from ( select object_name, object_id
from t sample ( 1 )
where object_name like '%%'
order by dbms_random.random )
where rownum <= 6;
更多精彩
赞助商链接