pagination display and optimization of data in Oracle

Source: Internet
Author: User

In a page is often the phenomenon of paging, then the background database should be how to page display it?

Paging can use the RowNum function in Oracle.

The display of data from the first line to the first row of a page.

Below is a description of the EMP table under the Scott User:

Statement one:

Select b.*
From
Select A.*, RowNum row_num
From (SELECT * from EMP) a) b
where row_num between 3 and 5;

Statement two:

Select b.*
From
Select A.*, RowNum row_num
From (SELECT * from EMP) a
where rownum<6) b
where row_num>2;

Statement one and statement two have the same function, can be the EMP table in the third row to the fifth row of data display, but when the data in the database is large, statement two is significantly more optimized than the statement one.

In Oracle, the execution of SQL statements is executed from the inside out, in which the rownum<6 data is first put into table B, and then the ROWNUM>2 data is queried from table B, which is more efficient than statement I.

pagination display and optimization of data in Oracle

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.