Oracle paging query sorting data duplication problem

Source: Internet
Author: User

Resources:

http://docs.oracle.com/database/122/SQLRF/ROWNUM-Pseudocolumn.htm#SQLRF00255

http://blog.csdn.net/u010395242/article/details/52047341

In the following manner:

SELECT *   from(SELECTRow_.*, RowNum rownum_ from(SELECT *                   fromtable_nameWHERE 1 = 1                   ORDER  bytable_name.create_date) Row_WHERERowNum<= Ten) Table_aliasWHERETable_alias.rownum_> 0

In the paging query data, there is a phenomenon of duplication of data, through the data:

The reason for this problem is that in the data, the value of the row sequence is not unique, that is, the value of create_date is not unique.

In Oracle:

Oracle's paging query is no sort operation, and Oracle is sequentially reading the qualifying data from the data block back to the client.

While Oracle's sorting algorithm is not stable, that is, for data with key values equal, this algorithm does not guarantee the order in which the data of these key values are equal before the sorting is done.

The workaround is as follows (two conditions must be met at the same time):
A sort condition is required in a 1.sql statement.
2. Sorting criteria if there is no uniqueness, then you must follow a unique condition, such as a primary key, behind it.

Oracle paging query sorting data duplication problem

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.