[DB2] fetch-first-clause

Dev/DB 2012. 7. 20. 13:54

The FETCH FIRST clause limits the number of rows that can be fetched. It

improves the performance of queries with potentially large result tables when only

a limited number of rows are needed.


출처 : DB2® Version 9.1 for z/OS® SQL Reference (SC18-9854-12)


---------------

How to Limit Query Results for DB2 Databases

Many times users are only interested in a subset of the results returned from an SQL query. DB2 provides a mechanism for limiting the records returned from an SQL query with the FETCH FIRST command. Using the FETCH FIRST syntax improves the performance of queries when not all results are required. Listed below are some examples explaining how to use FETCH FIRST.

Example 1: Returning the first 100 rows from a table called employee:

select * from employee fetch first 100 rows only

Example 2: Using the fetch first syntax with an order by clause

select * from employee order by salary desc fetch first 10 rows only 




자세한 정보는 아래 문서에서 확인.

출처 : http://www.razorsql.com/articles/db2_limit_query.html


Posted by pwsunf
,