How to limit the number of rows in an ORACLE query?

Once I was doing an integration between two distinct banks: MySQL and PostgreSQL.
During work it was very common for me to have to limit the amount of records to make it easier to see what I need it and for this, both in one and the other, I use the command “LIMIT <number of lines>“.

It turns out that in Oracle this command does not exist, so, how can I limit the number of records in a query in Oracle?

Well, for those who do not know, Oracle has a pseudocolumn called ROWNUM that can be used for this purpose.  So every time you use it you can reduce the number of lines and bring the result a little faster.

Example: SELECT empno, first_name, last_name FROM EMPLOYEES WHERE ROWNUM <= 10;

It’s a tip for your day-to-day, blz.

Inquiries, please contact us.

Strong hug.

Eduardo Sananta
bufallos@bufallos.com.br

Leave a Reply

Your email address will not be published. Required fields are marked *