Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: A few simple Oracle questions
On Wed, 01 Apr 1998 22:22:38 -0800, "Mark W. Eaton" <eaton_at_best.com> wrote:
>Our organization is relatively new to Oracle but fairly seasoned with SQL Server
>development. We have a few questions we need to understand to make the
>transition as quickly as possible. Please respond directly via email as I do
>not read this newsgroup regularly,
>
>Sincerely,
>Mark Eaton
>eaton_at_best.com
>
>-----------------------------------------------------------------------
>SQL*Plus related
>--------------------------
>How do I tell the Server to return only a fixed number of rows in response to a
>query.
>In isql (Sybase) I would say
>set rowcount 10
>select fld1 from table1 where fld2 > 100
>This would return the first 10 rows that fulfilled the condition.
>How do I achieve the same in SQL*Plus. There does not seem any
>environment variable that I can set.
Try this:
select fld1 from table1 where fld2 > 100 AND ROWNUM < 11;
SQL Reference:
ROWNUM For each row returned by a query, the ROWNUM pseudocolumn returns a number indicating the order in which Oracle7 selects the row from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second has 2, and so on.
You can use ROWNUM to limit the number of rows returned by a query, as in this example:
SELECT *
FROM emp WHERE ROWNUM < 10>OCI related
>------------------------------------------------------------------------