What are the functions of the oracle limit feature?
The LIMIT feature in Oracle includes the following options:
- FETCH FIRST n ROWS ONLY: Used to retrieve the first n rows of records from a query result.
For example: SELECT * FROM table_name FETCH FIRST 5 ROWS ONLY; - ROWNUM: used to restrict the number of rows in query results.
For example: SELECT * FROM table_name WHERE ROWNUM <= 5; - Skip the first n rows in the query result and return the next m rows. For example: SELECT * FROM table_name OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY;
- TOP n: used to return the first n rows of query results, similar to FETCH FIRST n ROWS ONLY.
For example: SELECT TOP 5 * FROM table_name;
It is important to note that in Oracle databases, there is no direct use of the LIMIT keyword to limit the number of rows in query results, but the above method is used instead.