在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条