Databases :: Oracle :: LIMIT clause in Oracle ? |
|||
| By: tiscaliBE |
Date: 28/12/2004 09:00:43 |
Points: 20 | Status: Answered Quality : Excellent |
|
Me again ;-) I want to restrict the results set in Oracle to prevent the client (be it TOAD or my scripts) from returning all the rowset (potentially enormous) but only the first 10 lines or so. I know in some RDBMS you can add a "LIMIT n,m" clause at the end of the SELECT statement. This has the result of limiting the rowset to the "n to m"-th lines How can I do this in Oracle ? This multi-million dollars system seems to be lacking such a simple&useful "enhancement" to SQL. |
|||
| By: VGR | Date: 29/12/2004 09:04:23 | Type : Answer |
|
| you're right again about Oracle lacking "LIMIT" 1) for a "simple" query with a clause "LIMIT 25" (ie, the first 25 rows only), do execute this : $sql = "select * from ($real_sql) where rownum<=25"; 2) for a more complex query with a "limit 10,30" clause, use that : $sql = "SELECT $fields FROM (SELECT rownum as db_rownum, $fields FROM ($real_sql) WHERE rownum<=30) WHERE db_rownum >=10"; Best regards and welcome in the wonderful world of "Oracle, the most powerful RDBMS in the world" :D |
|||
| By: Bernard | Date: 30/12/2004 08:49:25 | Type : Comment |
|
| yes, the infamous pseudo-column "rownum" is the way to go | |||
| By: tiscaliBE | Date: 30/12/2004 12:55:52 | Type : Comment |
|
| thanks ;-) | |||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








