Return-Path:
Derby supports limiting the number of rows returned by a query through
- JDBC.
+ JDBC. For example, to fetch the first 5 rows of a large table:
+
+
+Statement stmt = con.createStatement();
+
+ Some related tuning tips are available in
+ this
+ external article.
+
+ Starting with the 10.4.1.3 release Derby also supports limiting the number of
+ rows using the ROW_NUMBER function.
+
+ For example, to fetch the first 5
+ rows of a large table:
+
+
+SELECT * FROM (
+
+ The ROW_NUMBER function can also be used to select a
+ limited number of rows starting with an offset, for example:
+
+
+SELECT * FROM (
+
+ For more information, refer to the ROW_NUMBER built-in function in
+ the Derby Reference Manual (available from the
+ Documentation page). Development
+ notes are available on the
+ OLAPRowNumber
+ wiki page.
+
+ The LIMIT keyword is not defined in the SQL standard,
+ and is currently not supported.
+
+stmt.setMaxRows(5);
+
+
+ResultSet rs = stmt.executeQuery("SELECT * FROM myLargeTable");
+
+
+
+ SELECT ROW_NUMBER() OVER() AS rownum, myLargeTable.*
+
+ FROM myLargeTable
+
+
+) AS tmp
+
+
+WHERE rownum <= 5;
+
+
+
+ SELECT ROW_NUMBER() OVER() AS rownum, myLargeTable.*
+
+ FROM myLargeTable
+
+
+) AS tmp
+
+
+WHERE rownum > 200000 AND rownum <= 200005;
+
+
+5.3.
Why do I get the error 'schema does not exist'?
@@ -810,7 +883,7 @@
to create in a particular schema and no explicit CREATE SCHEMA was issued.
Derby supports limiting the number of rows returned by a query through - JDBC. + JDBC. For example, to fetch the first 5 rows of a large table: +
+ +
+ Statement stmt = con.createStatement();
+ stmt.setMaxRows(5);
+ ResultSet rs = stmt.executeQuery("SELECT * FROM myLargeTable");
+
+ Some related tuning tips are available in + this + external article. +
+
+ Starting with the 10.4.1.3 release Derby also supports limiting the number of
+ rows using the ROW_NUMBER
function.
+
+ For example, to fetch the first 5 + rows of a large table: +
+
+ SELECT * FROM (
+ SELECT ROW_NUMBER() OVER() AS rownum, myLargeTable.*
+ FROM myLargeTable
+ ) AS tmp
+ WHERE rownum <= 5;
+
+ The ROW_NUMBER
function can also be used to select a
+ limited number of rows starting with an offset, for example:
+
+ SELECT * FROM (
+ SELECT ROW_NUMBER() OVER() AS rownum, myLargeTable.*
+ FROM myLargeTable
+ ) AS tmp
+ WHERE rownum > 200000 AND rownum <= 200005;
+
+ For more information, refer to the ROW_NUMBER built-in function in + the Derby Reference Manual (available from the + Documentation page). Development + notes are available on the + OLAPRowNumber + wiki page. +
+
+ The LIMIT
keyword is not defined in the SQL standard,
+ and is currently not supported.