首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

ORACLE/MSSQL随机取一条记要方法

2012-09-08 
ORACLE/MSSQL随机取一条记录方法oracle随机取数据:select * from (select * from sys_dict order by sys_g

ORACLE/MSSQL随机取一条记录方法

oracle随机取数据:

select * from (                   select * from sys_dict order by sys_guid()           )where rownum =1

?

oracle随机取数据2:

select *  from (           select * from sys_dict order by dbms_random.value           )where rownum <2

?

sqlserver 随机取数据:

select top 1 * from 表名 order by newid () 

?重点在于newid()生产随机值,

取多条则将top后面数字改成具体数量即可

?

热点排行