Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 7414 invoked from network); 3 Mar 2009 08:49:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Mar 2009 08:49:17 -0000 Received: (qmail 28011 invoked by uid 500); 3 Mar 2009 08:49:17 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 27992 invoked by uid 500); 3 Mar 2009 08:49:17 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 27983 invoked by uid 99); 3 Mar 2009 08:49:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2009 00:49:17 -0800 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.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2009 08:49:16 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 37B28234C4AE for ; Tue, 3 Mar 2009 00:48:56 -0800 (PST) Message-ID: <972376093.1236070136226.JavaMail.jira@brutus> Date: Tue, 3 Mar 2009 00:48:56 -0800 (PST) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-4) "order by" is not supported for "insert ... select" In-Reply-To: <996458618.1096307672163.JavaMail.apache@nagoya> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-4?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678264#action_12678264 ] Knut Anders Hatlen commented on DERBY-4: ---------------------------------------- It might be worth checking if SQL 2008 allows ORDER BY in INSERT INTO ... SELECT FROM ... . Dag wrote the following in DERBY-4079: > Note that both ORDER BY and the new clauses above are allowed also in > subqueries in the new version of the SQL standard (section 7.13). I > only propose to include this at the top level in DERBY for now. (ORDER > BY is presently also not allowed in subqueries in Derby since SQL > didn't allow for this until SQL 2008 either). > "order by" is not supported for "insert ... select" > --------------------------------------------------- > > Key: DERBY-4 > URL: https://issues.apache.org/jira/browse/DERBY-4 > Project: Derby > Issue Type: New Feature > Components: SQL > Reporter: Christian d'Heureuse > Priority: Minor > Attachments: insertOrderBy.diff, insertOrderBy_v2.diff, insertOrderBy_v3.diff, samples.ij, samples.ij > > > When filling a table with "insert ... select ...", "order by" cannot be specified. > There is not method to copy a table sorted into another table (except using export/import). This would be useful to optimize performance for big tables, or to create identity values that are ascending (related to another column). > Example: > create table temp1 ( > s varchar(10)); > insert into temp1 values 'x','a','c','b','a'; > create table temp2 ( > i integer not null > generated always as identity > primary key, > s varchar(10)); > insert into temp2 (s) > select s from temp1 order by s; > --> Error: "order by" is not allowed. > -- trying to use "group by" instead of "oder by": > insert into temp2 (s) > select s from temp1 group by s; > select * from temp2; > --> "group by" did not sort the table. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.