六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 110|回复: 0

Oracle 12c新特性之翻页查询

[复制链接]

升级  3.2%

168

主题

168

主题

168

主题

进士

Rank: 4

积分
516
 楼主| 发表于 2013-1-29 14:46:16 | 显示全部楼层 |阅读模式
在即将发布的oracle 12c中,有一个新特性非常值得期待,这就是翻页查询优化。
在应用中有很多翻页查询功能,以前我们都是使用rownum来实现。
如查询1-10条记录,使用的查询语句就是这样:
 
select *  from (select row_.*, rownum rownum_          from (select doc_id,                       title,                       title_color,                       title_striking,                       upload_date,                       editor                  from ttt_doc)         order by upload_date desc) row_ where rownum <= 10) where rownum_ > 0;   
(miki西游 @mikixiyou 原文链接: http://mikixiyou.iteye.com/blog/1685165)
 
在12c中,可以这样做了。
 
select doc_id, title, title_color, title_striking, upload_date, editor  from ttt_doc order by upload_date desc fetch first 10 rows only;  
 
如果你要查询11到20条的记录,那么你可以这样做。
 
select doc_id, title, title_color, title_striking, upload_date, editor  from ttt_doc order by upload_date desc offset 10 rows fetch next 10 rows only;   
 
这样比以前的操作方便多了。当然,更重要的一点是,性能会大幅提升。
 
如果您希望了解更详细的信息,可去查阅oracle 12c的文档。
 
--end
 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表