Oracle数据库用SQL实现快速分页
Oracle采用嵌套3层的查询语句结合rownum来实现分页,这在Oracle上是最快的方式,如果只是一层或者两层的查询语句的rownum不能支持order by。
程序:
public String getLimitString(String sql) {
StringBuffer pagingSelect = new StringBuffer(100);
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
pagingSelect.append(sql);
pagingSelect.append(" ) row_ where rownum ?");
return pagingSelect.toString();
}
sql实例:
select * from ( select row_.*, rownum rownum_ from (select * from scott.emp ) row_ where rownum 2;
相关推荐
oraclemch 2020-11-06
Seandba 2020-08-16
dbasunny 2020-08-16
娜娜 2020-06-22
whyname 2020-08-16
明月清风精进不止 2020-07-05
URML 2020-07-04
CSDN0BLOG 2020-06-21
goodriver 2020-06-17
专注前端开发 2020-10-21
苏康申 2020-11-13
vitasfly 2020-11-12
liuyang000 2020-09-25
FellowYourHeart 2020-10-05
赵继业 2020-08-17
拼命工作好好玩 2020-08-15
langyue 2020-08-15