Java Blog for Alex Wan

Let life be beautiful like summer flowers and death like autumn leaves.

统计

留言簿(10)

BlogJava

Blogs

DIV+CSS

JQuery相关

友情链接

常去的地方

数据供应

阅读排行榜

评论排行榜

从SQLSERVER与ORACLE数据库中随机取记录

在sql server中,从数据表中随机取出n条记录,使用以下SQL语句:

select top n * from tableName order by newid()

在oralce中,从数据表中随机取出n条记录,使用以下SQL语句

select   *   from   (select   tableName .*,dbms_random.random  as randomKey   from tableName  order  by   randomKey)    
  
where   rownum<=n


Let life be beautiful like summer flowers and death like autumn leaves.

posted on 2008-08-21 16:53 Alexwan 阅读(494) 评论(0)  编辑  收藏 所属分类: 小笔记数据库


只有注册用户登录后才能发表评论。


网站导航: