Introduction to paging query in Oracle, SQL, and DB2

Source: Internet
Author: User
Tags db2 sql statements ibm db2

The paging query method of DB2 is not the same as that of paging query statements in Oracle and SQL. The following describes the differences between paging query in DB2 and paging query in other databases.

Oracle paging query statement:

I. Oracle 

 
Select * from (selectRownum, Name from table whereRownum <= endindex and rownum> startindex)

Ii. DB2

DB2 paging Query

 
  
  
  1. Select * from (select Field 1, Field 2, Field 3,Rownumber () over (column name ASC used for order by sorting) as RnFrom table name) as A1 where a1.rnBetween 10 and 20

The above indicates that 10th to 20 records are extracted.

Select * from (selectRownumber () over (order by id asc) as rowidFrom table whereRowid<= Endindex and rowid>Startindex

Note: The preceding DB2 SQL statements are available in IBM DB2 UDBV8.2And
V9.7After the test is passedRownumber ()ChangeRow_number (), Verification passed.

Iii. MySQL:

 
Select * from tableLimit start, pagenum 

 

original article address: http://database.51cto.com/art/201011/232337.htm

Related Article

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.