ORACLE SQL ROWNUM执行顺序 [英] ORACLE SQL ROWNUM execution order

查看:212
本文介绍了ORACLE SQL ROWNUM执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Oracle SQL中,有一个可能的条件称为rownum.我可以确认行数最终将仅作为返回记录数的限制而执行吗? 还是可以先执行它,然后再执行其他WHERE SQL条件(如果我们将rownum放在其他条件之前,让我们先执行)?

in Oracle SQL, there is a possible criteria called rownum. Can i confirm that rownum will be executed at last as just a limit for number of records return? or could it be executed first, before other WHERE SQL criteria (let's if we put rownum prior to the others)?

推荐答案

与其他语言中的LIMIT不等效.如果计划使用rownum限制记录数,则需要在内部对ORDER BY进行子查询,并在外部查询中使用rownum. WHERE子句中元素的顺序无关紧要. 请参见Tom的这篇出色的文章 Kyte.

It's not the equivalent of LIMIT in other languages. If you plan on limiting the number of records with rownum, you'll need to subquery the ORDER BY on the inside and use rownum in the outer query. Order of elements in your WHERE clause does not matter. See this excellent article by Tom Kyte.

这篇关于ORACLE SQL ROWNUM执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆