Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 60763 invoked from network); 7 May 2008 13:50:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 May 2008 13:50:52 -0000 Received: (qmail 5515 invoked by uid 500); 7 May 2008 13:50:54 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 5485 invoked by uid 500); 7 May 2008 13:50:54 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 5474 invoked by uid 99); 7 May 2008 13:50:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 06:50:54 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 13:50:05 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5B0CA2388A09; Wed, 7 May 2008 06:50:20 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r654105 - in /db/derby/site/trunk: build/site/faq.html src/documentation/content/xdocs/faq.xml Date: Wed, 07 May 2008 13:50:19 -0000 To: derby-commits@db.apache.org From: johnemb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080507135020.5B0CA2388A09@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: johnemb Date: Wed May 7 06:50:18 2008 New Revision: 654105 URL: http://svn.apache.org/viewvc?rev=654105&view=rev Log: DERBY-232: FAQ: Updated answer for LIMIT question. Added examples for Statement.setMaxRows() as well as ROW_NUMBER (new in 10.4), and a couple of links. Modified: db/derby/site/trunk/build/site/faq.html db/derby/site/trunk/src/documentation/content/xdocs/faq.xml Modified: db/derby/site/trunk/build/site/faq.html URL: http://svn.apache.org/viewvc/db/derby/site/trunk/build/site/faq.html?rev=654105&r1=654104&r2=654105&view=diff ============================================================================== --- db/derby/site/trunk/build/site/faq.html (original) +++ db/derby/site/trunk/build/site/faq.html Wed May 7 06:50:18 2008 @@ -775,10 +775,83 @@

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.

- +

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.

- +

5.4. I get a lock timeout error. How do I debug this?

@@ -839,7 +912,7 @@ to narrow down which statements may be holding the locks.

- +

5.5. Can Derby generate unique identifiers like sequences?

@@ -856,9 +929,9 @@ function returns the most recently assigned number.

- +

6. Using Derby: Client Programming

- +

6.1. Can you use Derby for client-server applications?

@@ -879,7 +952,7 @@ Sequoia.

- +

6.2. Does Derby include a client-server ("network") jdbc driver?

@@ -895,7 +968,7 @@ and it became available starting with Derby 10.1.

- +

6.3. How can I get the message text for an error using the DB2 JDBC Universal Driver? @@ -913,7 +986,7 @@ mail list topic.

- +

6.4. Can you execute a query that spans two Derby databases across different JVMs? @@ -929,7 +1002,7 @@ Admin and Server Guide.

- +

6.5. Are there any tips to make Derby go faster?

@@ -964,7 +1037,7 @@ - +

6.6. Where is an example that shows how to insert a CLOB?

@@ -982,7 +1055,7 @@ provides another example.

- +

6.7. Does Derby support JDBC 4.0?

Modified: db/derby/site/trunk/src/documentation/content/xdocs/faq.xml URL: http://svn.apache.org/viewvc/db/derby/site/trunk/src/documentation/content/xdocs/faq.xml?rev=654105&r1=654104&r2=654105&view=diff ============================================================================== --- db/derby/site/trunk/src/documentation/content/xdocs/faq.xml (original) +++ db/derby/site/trunk/src/documentation/content/xdocs/faq.xml Wed May 7 06:50:18 2008 @@ -412,7 +412,60 @@

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.