Paging methods for oracle, mysql, and teradata

Source: Internet
Author: User

Oracle, mysql, teradata paging method/*** add paging information to the original SQL statement * @ param SQL the SQL statement to add paging * @ param start the start position of the record * @ param limit the record to be displayed number * @ return: converted SQL */public static String addPageForOracle (String SQL, int start, int limit) {int end = start + limit; SQL = "select * from (select t. *, rownum rn from ("+ SQL +") t where rownum <= "+ end +") t1 where t1.rn> "+ start +" "; return SQL ;} /*** add paging information on the original SQL statement * @ param SQL the SQL statement to add paging * @ param start the start position of the record * @ param limit the number of records to be displayed *@ return converted SQL */public static String addPageForMySql (String SQL, int start, int limit) {SQL = SQL + "limit" + start + "," + limit; return SQL;} public String addPageForTeraData (String SQL, int start, int limit) {SQL = SQL + "QUALIFY sum (1) over (rows unbounded preceding) between (" + start + ") and (" + limit + ")"; return SQL ;}

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.