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条

posted @ 2018-04-16 10:01  小小邪  阅读(2509)  评论(0编辑  收藏  举报