從SQLSERVER與ORACLE數(shù)據(jù)庫中隨機(jī)取記錄
在sql server中,從數(shù)據(jù)表中隨機(jī)取出n條記錄,使用以下SQL語句:
select top n * from tableName order by newid()
在oralce中,從數(shù)據(jù)表中隨機(jī)取出n條記錄,使用以下SQL語句
select * from (select tableName .*,dbms_random.random as randomKey from tableName order by randomKey)
where rownum<=n
where rownum<=n
Let life be beautiful like summer flowers and death like autumn leaves.
posted on 2008-08-21 16:53 Alexwan 閱讀(506) 評(píng)論(0) 編輯 收藏 所屬分類: 小筆記 、數(shù)據(jù)庫