從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
where rownum<=n
Let life be beautiful like summer flowers and death like autumn leaves.
posted on 2008-08-21 16:53 Alexwan 閱讀(502) 評論(0) 編輯 收藏 所屬分類: 小筆記 、數據庫