oracle和sql server中,取前10條數據語法的區別


在sql server中,取數據中前10條語句,我們可以用top 10 這樣語句,但是oracle就沒有這個函數,接下來介紹它們之間的區別

1、sql server 取前10語句和隨機10條的語法

--測試表數據--
select * from BdsPaperItem
--查詢測試表的前10條語句--
select top 10 * from BdsPaperItem order by Uid asc
--隨機查詢測試表10條語句--
select top 10 * from BdsPaperItem order by NEWID()

結果實例:

1)測試表數據

2)取前10條

3)隨機取10條

2、Oracle 取前10條和隨機10條語法

-- 測試表數據 --
select * from Dxc_Goods_Cate  
-- 查詢數據表前10 條語句 --
select * from Dxc_Goods_Cate where rownum <= 10 order by MID asc
-- 查詢數據表第11到20 條語句 --
select * from (select rownum rn,A.* from Dxc_Goods_Cate A )
where rn>10 and rn<=20 
order by MID asc
-- 查詢數據表隨機10條語句 --
select * from
(
 select  *  from Dxc_Goods_Cate
 order by dbms_random.value
)
 where rownum <= 10;

結果實例:

1)測試表數據

2)取前10條

3)取11到20條

4)隨機取10條


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM