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 閱讀(502) 評論(0)  編輯  收藏 所屬分類: 小筆記數據庫

          主站蜘蛛池模板: 万源市| 达日县| 临夏市| 米脂县| 成安县| 高碑店市| 宁陵县| 达孜县| 乐陵市| 南城县| 阿克苏市| 太谷县| 观塘区| 古丈县| 勃利县| 治多县| 德安县| 江口县| 海安县| 涿鹿县| 保康县| 建阳市| 凤庆县| 吐鲁番市| 开封县| 定陶县| 夹江县| 鹤庆县| 银川市| 离岛区| 麻阳| 夏河县| 崇信县| 周至县| 临潭县| 利津县| 宁城县| 益阳市| 呼伦贝尔市| 高要市| 长宁区|