X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D00CCD1B179 for ; Fri, 2 Jul 2004 17:07:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47807-02 for ; Fri, 2 Jul 2004 20:07:47 +0000 (GMT) Received: from mxc.pcnet.ro (unknown [82.137.14.5]) by svr1.postgresql.org (Postfix) with ESMTP id 22C3BD1B387 for ; Fri, 2 Jul 2004 17:07:43 -0300 (ADT) Received: from aldratech.com (aldratech.com.pcnet.ro [213.154.158.58] (may be forged)) by mxc.pcnet.ro (8.12.10/8.12.10) with ESMTP id i62K7adv026169 for ; Fri, 2 Jul 2004 23:07:37 +0300 Received: from aldratech.com ([192.168.0.6]) by aldratech.com for with eXtremail; Fri, 2 Jul 2004 23:07:43 +3GMT Message-ID: <40E5C188.7010005@aldratech.com> Date: Fri, 02 Jul 2004 23:11:52 +0300 From: Radu-Adrian Popescu Reply-To: radu.popescu@aldratech.com Organization: Aldratech Ltd. User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.6) Gecko/20040510 X-Accept-Language: en-us, en MIME-Version: 1.0 To: teknet@poczta.onet.pl Cc: pgsql-admin@postgresql.org Subject: Re: SERIAL type not autoincremented References: <20040702194010Z137290-15166+26852@kps2.test.onet.pl> In-Reply-To: <20040702194010Z137290-15166+26852@kps2.test.onet.pl> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/50 X-Sequence-Number: 14118 teknet@poczta.onet.pl wrote: > i found the problem: > > > > sys=> insert into test2 values(1,'myname'); > INSERT 18765 1 > sys=> insert into test2 (name) values('myname2'); > ERROR: duplicate key violates unique constraint "test2_pkey" > sys=> > > Why is it so ? > Because you explicitly put in 1: values(1,'myname') and the second insert values('myname2') which is short for values(default, 'myname2') gets the value for the ID column from the default (which is nextval('test2_id_seq')) and that's 1 too - there you go, unique constraint violation. Remember, this is _not_ mysql, where autoincrement columns are implemented(or so I hear) by select max(column_in_question) + 1. > > > Thanx > > Michal > Take care and do read/search the manual, it's quite good ! Regards, -- Radu-Adrian Popescu CSA, DBA, Developer Aldrapay MD Aldratech Ltd. +40213212243