Differences

This shows you the differences between two versions of the page.

db2-to-oracle:fetch_first_rows_only [April 23, 2013 7:18 am]
sqlines
db2-to-oracle:fetch_first_rows_only [January 02, 2018 11:39 am] (current)
sqlines
Line 1: Line 1:
====== FETCH FIRST n ROWS ONLY - IBM DB2 to Oracle Migration ====== ====== FETCH FIRST n ROWS ONLY - IBM DB2 to Oracle Migration ======
-In DB2, you can use FETCH FIRST //n// ROWS ONLY clause in a SELECT statement to return only //n// rows, and it is applied after rows are sorted as specified in the ORDER BY clause. {{:exclamation.png|}}+In DB2, you can use FETCH FIRST //n// ROWS ONLY clause in a SELECT statement to return only //n// rows, and this limit is applied after sorting the rows as specified in the ORDER BY clause. {{:exclamation.png|}}
-**IBM DB2**+**IBM DB2:**
<code sql> <code sql>
Line 47: Line 47:
===== FETCH FIRST n ROWS ONLY in Oracle ===== ===== FETCH FIRST n ROWS ONLY in Oracle =====
-In Oracle, you can use ROWNUM pseudo-column to limit the number of retrieved rows, but it is applied before sorting, so you have to use a sub-query in order to limit the number of rows after sorting.{{:exclamation.png|}}+Note that starting from Oracle 12c you can also use FETCH FIRST clause in Oracle, so the conversion is not required. {{:exclamation.png|}} 
 + 
 +Prior Oracle 12c you can use the ROWNUM pseudo-column to limit the number of retrieved rows, but it is applied before sorting, so you have to use a sub-query in order to limit the number of rows after sorting.{{:exclamation.png|}}
If there is no ORDER BY clause in the original DB2 query, you can just add ROWNUM condition as follows: If there is no ORDER BY clause in the original DB2 query, you can just add ROWNUM condition as follows:
Line 81: Line 83:
| New York | | New York |
-===== More Information =====+For more information, see
  * [[/db2-to-oracle|IBM DB2 to Oracle Migration Tools and Reference]]   * [[/db2-to-oracle|IBM DB2 to Oracle Migration Tools and Reference]]
- 
-===== About SQLines ===== 
- 
-SQLines offers services and tools to help you migrate databases and applications. For more information, please contact us at [[support@sqlines.com]].  
- 
-//Written by// Dmitry Tolpeko - April 2013. 
~~NOTOC~~ ~~NOTOC~~
~~DISCUSSION~~         ~~DISCUSSION~~