Row limiting clause clause allows sql queries to limit the number of rows returned and to specify a starting row for the return set.

1. Fetch first N rows:

 
SQL> select * from test2 fetch first 5 rows only;
 
OWNER    OBJECT_NAME           STATUS
-------- --------------------- -------
SYS      I_CCOL1               VALID
SYS      I_PROXY_ROLE_DATA$_1  VALID
SYS      C_OBJ#                VALID
SYS      CON$                  VALID
SYS      I_USER1               VALID

2. Fetch 5 rows after offset of 4 rows

	
 
SQL> select * from test2 a OFFSET 4 ROWS FETCH NEXT 5 ROWS ONLY;  2
 
OWNER    OBJECT_NAME           STATUS
-------- --------------------- -------
SYS      I_USER1               VALID
SYS      COL$                  VALID
SYS      PROXY_DATA$           VALID
SYS      I_CON2                VALID
SYS      I_UNDO1               VALID

3. Fetch percentage of rows from a query:

SELECT *  from test2  
FETCH FIRST 1 PERCENT ROWS ONLY;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.