Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92433421
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-04 11:49:24

     来源:赛迪网    作者:liumingzhao

问:能否给我介绍一种随机抽取记录的方法?

答:以下代码以抽取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;
阅读(284) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~