Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 53277 invoked from network); 25 May 2009 18:36:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 May 2009 18:36:57 -0000 Received: (qmail 22556 invoked by uid 500); 25 May 2009 18:37:09 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 22499 invoked by uid 500); 25 May 2009 18:37:09 -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 22491 invoked by uid 99); 25 May 2009 18:37:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 May 2009 18:37:09 +0000 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; Mon, 25 May 2009 18:37:06 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 976CC234C004 for ; Mon, 25 May 2009 11:36:45 -0700 (PDT) Message-ID: <565451722.1243276605606.JavaMail.jira@brutus> Date: Mon, 25 May 2009 11:36:45 -0700 (PDT) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-3) Identity column not filled consecutively with "insert ... select distinct" In-Reply-To: <256101855.1096306352155.JavaMail.apache@nagoya> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712767#action_12712767 ] Knut Anders Hatlen commented on DERBY-3: ---------------------------------------- Just to add another data point, the identity values are consecutive if you put another query around the select distinct: ij> insert into temp2 (s) select * from (select distinct s from temp1) t; 4 rows inserted/updated/deleted ij> select * from temp2; I |S ---------------------- 1 |d 2 |b 3 |c 4 |a 4 rows selected For some reason, the ordering is different too. > Identity column not filled consecutively with "insert ... select distinct" > -------------------------------------------------------------------------- > > Key: DERBY-3 > URL: https://issues.apache.org/jira/browse/DERBY-3 > Project: Derby > Issue Type: Improvement > Components: SQL > Affects Versions: 10.2.1.6 > Environment: Derby Snapshot svnversion 46005 > or Cloudscape 10.0 GA > Derby 10.2beta > Reporter: Christian d'Heureuse > Priority: Minor > > When an "insert ... select distinct" is used to fill a table with an identity column, gaps occur in the identity column. The caps correspond to the rows of the source table that have been suppressed with "distinct". > Example: > create table temp1 ( > s varchar(10)); > insert into temp1 values 'a','a','a','b','c','c','c','d'; > create table temp2 ( > i integer not null > generated always as identity > primary key, > s varchar(10)); > insert into temp2 (s) > select distinct s from temp1; > select * from temp2; > output: > 1 a > 4 b > 5 c > 8 d -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.