Oracle:rownum principle

Source: Internet
Author: User

RowNum principle:

1 Oracle executes your query.

Perform a query operation

2 Oracle fetches the first row and calls it row number 1.

Place row num on the first row at 1

3 have we gotten past row number meets the criteria? If no, then Oracle discards the row, if yes, then Oracle return the row.

The resulting row's row num is compared to the condition and if it does not match, the row is discarded, and if it matches, the row is returned

4 Oracle fetches the next row and advances the row number (to 2, and then to 3, and then to 4, and so forth).

Oracle gets the next line, and then increases the rownum by 1

5 Go to step 3.

Return to step 3rd

From this principle it is known that theselect Rownum,name from emp where rownum>5; does not return rows because the query is executed first by the select name from EMP, and the 1th row of rownum is labeled 1, Then look at the where condition, false, then discard the row, execute line 2nd, or rownum labeled 1, see where condition is also false, so forever is false,rownum do not change, all rows are discarded, so there is no result.

where rownum = N (n>1)

where rownum > N are not available, which is the reason above

Oracle:rownum principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.